哦最开始还以为是个什么难题,哦原来是秦九韶,哦我不会秦九韶
哦我们把x往外提一下,哦!这复杂度怎么就O(nm)了啊!
哦好事,这题已经是A了,哎woc怎么一直WA啊!
哦原来读入的数最大为10^1000,哦我快读没取模,哦好事
哦已经是A了
考验选手的乱搞能力
1 #include<bits/stdc++.h> 2 #define ll long long 3 #define uint unsigne int 4 #define ull unsigned long long 5 using namespace std; 6 const ll mod = 19260817; 7 const int maxn = 500010; 8 const int maxm = 1000010; 9 ll a[maxn]; 10 ll n, m; 11 ll ans[maxn], tot = 0; 12 bool flag = 0; 13 14 inline ll read() { 15 ll x = 0, y = 1; 16 char ch = getchar(); 17 while(!isdigit(ch)) { 18 if(ch == '-') y = -1; 19 ch = getchar(); 20 } 21 while(isdigit(ch)) { 22 x = ((x << 1) % mod + (x << 3) % mod + ch - '0') % mod; 23 ch = getchar(); 24 } 25 return x * y; 26 } 27 28 inline bool check(ll x) { 29 ll sum = 0; 30 for(register ll i = n; i >= 1; --i) 31 sum = ((sum + a[i]) * x) % mod; 32 sum = (sum + a[0]) % mod; 33 return !sum; 34 } 35 36 int main() { 37 n = read(), m = read(); 38 for(register ll i = 0; i <= n; ++i) a[i] = read(); 39 for(register ll i = 1; i <= m; ++i) 40 if(check(i)) { 41 flag = 1; 42 ans[++tot] = i; 43 } 44 printf("%lld ", tot); 45 for(register ll i = 1; i <= tot; ++i) 46 printf("%lld ", ans[i]); 47 return 0; 48 }