# Equation of noip2014 Solution

Source: Internet
Author: User

Equation of P2312 Solution
• 206 through
• 1.7K Submit
• Topic provider The user does not exist
• Tag number theory (mathematics-related) high-precision Noip raising group
• Difficulty Increase +/province selection-

Submit a discussion of the problem record

Recent discussions
• To correct the range of data
Title Description

Known polynomial equation:

a0+a1x+a2x^2+. +anx^n=0

The integer solution of this equation in [1, M] (both N and m are positive integers)

Input output Format input format:

The input file name is equation. In.

Enter a total of n + 2 rows.

The first line contains 2 integers n, m, separated by a space between each of the two integers.

The next n+1 line contains an integer for each row, followed by A0,A1,A2. An

Output format:

The output file is named equation. Out.

The number of integer solutions in the first row of the output equation in [1, M].

Next, each line of an integer, according to the order from small to large output equation in [1, M] an integer solution.

Input and Output Sample input example # #:
`2 10 1-21`
Sample # # of output:
`11`
Input Sample #:
`2 102-31`
Output Example #:
`212`
Input Sample # #:
`2 1  3  2   `
Output Sample # #:
`0`
Description

30%:0<n<=2,|ai|<=100,an!=0,m<100

50%:0<n<=100,|ai|<=10^100,an!=0,m<100

70%:0<n<=100,|ai|<=10^10000,an!=0,m<10000

100%:0<n<=100,|ai|<=10^10000,an!=0,m<1000000

Analysis: A long time ago, Abel proved that the unary n-th equation (n >= 5) is not the root formula, it seems that only 30% of the data can be violent, how can AC? It's about narrowing the data. It can be noted that AI and M are very large, m can't seem to shrink, how does ai shrink? Notice that this is an equation, then is the modulo operation, because to make the result of the equation is equal to 0, if f (x) = = 0, then f (x) mod p = = 0, but the converse does not necessarily set up, but if more than one enumeration of several p, the likelihood of AC is relatively large, less enumeration will WA, the enumeration This is the time to look at the face, this time to take a 10000 or so of prime numbers and a larger prime number (greater than M), why take prime? If AI equals 0 Then there is no point. Do you want an enumeration of x? It's too slow to notice that if f (x) mod p = = 0, then f (x + P) mod p = f (x) mod p + p mod p = = 0, so we add p on the basis of X continuously. In the calculation, once it is possible to exceed P, MoD.

`#include <cstdio>#include<cstring>#include<iostream>#include<algorithm>using namespacestd;Chars;intp, N, m;Long Longa[ the];BOOLcan;voidQuyu (Char*S1,intk) {    BOOLFu =false; intLen =strlen (S1), I;  for(intj =1; J <=2; J + +) {i=0; if(s1 =='-') {Fu=true; I=1; }         for(; i < Len; i++) A[j][k]= (a[j][k] * 10LL% p[j] + s[i]-'0') %P[j]; if(Fu = =true) A[j][k]= P[j]-A[j][k]; }}intPanduan (intXintk) {    Long LongAns =0, B =1;  for(inti =0; I <= N; i++) {ans= (ans + 1LL * a[k][i] * b)%P[k]; b= 1LL * b * x%P[k]; }    returnAns%p[k];}intMain () {p =67891, p =1000000207;//Two prime numbersscanf"%d%d", &n, &m);  for(inti =1; I <= m; i++) Can[i]=false;  for(inti =0; I <= N; i++) {scanf ("%s", s);               Quyu (S, i); }     for(inti =1; I <= p; i++)    {        if(Panduan (I,1) !=0)            Continue;  for(intj = i; J <= M; J + = p)            if(Panduan (J,2) ==0) Can[j]=true; }    intAns =0;  for(inti =1; I <= m; i++)        if(Can[i]) ans++; printf ("%d\n", ans);  for(inti =1; I <= m; i++)        if(Can[i]) printf ("%d\n", i); return 0;}`

Equation of noip2014 Solution

Related Keywords:

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.