2019多校集训赛散题(2022牛客国庆集训派对day5)

题目链接:https://ac.nowcoder.com/acm/contest/41759
好难,但这次相对简单,基础还是太差了,有的题目还是没法下手。
AC:3
Knowledge points:

链接:https://ac.nowcoder.com/acm/contest/41759/B 来源:牛客网

B.题目描述:
In mathematics, a polynomial is an expression consisting of variables (also called indeterminate) and coefficients, that involves only the operations of addition, subtraction, multiplication, and non-negative integer exponents of variables. For example, x2+4x+7. A polynomial is said to be irreducible if it cannot be factored into two or more non-trivial polynomials with real coefficients.
For example,x2+1 is irreducible, but x2-2x+1 is not (since x2-2x+1=(x-1)(x-1)).
Given a polynomial of degree n\n with integer coefficients:anxn+an-1xn-1+...+a1x+a0, you need to check whether it is irreducible or not.
输入描述:
The first line of the input gives the number of test cases, T(T<= 100) T test cases follow.
For each test case, the first line contains one integers n(0<=n<=20). Next line contains n+1 integer numbers:
an, an-1, ... a1, a0
输出描述:
For each test case, output "Yes" if it is irreducible, otherwise "No".
示例1
输入

2
2
1 -2 1
2
1 0 1
输出
No
Yes

思路:
数论知识,不可约只有单项式,一元多项式和二元多项式中的( Δ\Delta>0 ),只需要判断一下即可。
AC代码:

#include "iostream"
#include "cstring"
using namespace std;
const int N = 1e5+5;
typedef long long ll;
ll a[N];
int main(){
    int t, n;
    cin >> t;
    while(t--){
        cin >> n;
        for(int i = 0; i <= n; i++){
            cin >> a[i];
        }
        int f = 0;
        if(n <= 1){f = 1;}
        if(n == 2){
            if(a[1]*a[1] - 4*a[0]*a[2] < 0){f = 1;}
        }
        if(f){cout << "Yes" << endl;}
        else{cout << "No" << endl;}
    }
    system("pause");
    return 0;
}

D.题目描述
I have a very simple problem for you. Given a positive integeter n\ (1 \leq n \leq 1000000)n (1≤n≤1000000) and a prime number p\ (2 \leq p \leq 1000000)p (2≤p≤1000000), your job is to output a positive number which is divisible by p\p and has exactly n\n digits. Please output "T_T" if you can not find such number.
输入描述:
The first line of the input file contains two integers n\ (1 \leq n \leq 1000000)n (1≤n≤1000000) and p\ (2 \leq p \leq 1000000)p (2≤p≤1000000). p\ p is a prime number.
输出描述:
Output one number (without leading zeros) or "T_T".
示例1
输入

2 5

输出

10

示例2
输入

1 11

输出

T_T

示例3
输入

5 2

输出

10000

思路:能被p整除那么num位数必定>= p的位数,这就是判断"T_T"的条件,在num位数必定>= p的位数的条件下,那么必定有p*10x % p == 0; AC代码:

#include "iostream"
using namespace std;
int main(){
    int n, p;
    cin >> n >> p;
    int k = p, len = 0;
    while(k){
        len++;
        k /= 10;
    }
    if(len > n){
        cout << "T_T" << endl;
    }else{
        cout << p;
        int m = n-len;
        while(m--){
            cout << '0';
        }
        cout << endl;
    }
    return 0;
}