菜鸡的上分之路
1.快乐水题
Number
题意:给一个n和一个素数p,要求输出长度为n位且能被p整除的整数;
数据范围:
想法:先输出p,在用0补至n位;如果p的位数大于n,直接输出T_T;
代码:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll a,b;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
int n,p;
while(cin>>n>>p)
{
int len=0,tmp=p;
while(tmp)
{
len++;
tmp=tmp/10;
}
if(len>n)
{
cout<<"T_T\n";
}
else
{
cout<<p;
for(int i=0;i<n-len;i++)
{
cout<<"0";
}
cout<<"\n";
}
}
return 0;
}
Irreducible Polynomial
题意:tt组样例,每组样例给一个n以及n次多项式的各项系数,问这个多项式是否已经不可被因式分解;
数据范围: , , ,
想法:一次及以下和三次及以上的实数域多项式一定可以被因式分解,只要判断二次多项式判别式是否大于等于零;
代码:
#pragma GCC optimize(2)
#include <iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<vector>
#define FAST ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
const int maxn = 1e8;
ll coef[25];
int main() {
FAST;
ll t;
cin >> t;
while(t--) {
bool flag = 1;
ll n;
cin >> n;
for (ll i = n; i >=0; --i) {
cin >> coef[i];
}
if (n == 2) {
flag = (coef[1]*coef[1]-4*coef[0]*coef[2]<0);
}
if (n <= 1)cout << "Yes\n";
else if (n >= 3)cout << "No\n";
else cout << (flag ? "Yes\n" : "No\n");
}
}
持续加载ing…
转载:https://blog.csdn.net/weixin_43889301/article/details/98885848
查看评论