luogu P2312 解方程
二次联通门 : luogu P2312 解方程
/* luogu P2312 解方程 知道正解的我眼泪掉下来 原来模一模就能过。。 当时咋就不知道写呢。。。 */ #include <cstdio> #include <iostream> #include <cstring> #define Max 105 #define L 5 int Mod[L] = {9973,9931,9941,9949,9967}; int a[L][Max], cal[L][Max * 100], pre[L][Max]; int Answer[Max * 10000], C; void read (int &now) { register char c = getchar (); for (now = 0; !isdigit (c); c = getchar ()); for (; isdigit (c); now = now * 10 + c - '0', c = getchar ()); } char line[Max * 100]; inline bool Judge (int now) { for (int i = 0; i < L; ++ i) if (cal[i][now % Mod[i]]) return false; return true; } int Main () { freopen ("equation.in", "r", stdin); freopen ("equation.ans", "w", stdout); int N, M, Len; register int i, j, k; bool temp = false; read (N), read (M); for (i = 0; i <= N; ++ i) { temp = false; scanf ("%s", line); Len = strlen (line); if (line[0] == '-') temp = true; else if (isdigit (line[0])) for (j = 0; j < L; ++ j) a[j][i] = line[0] - '0'; for (j = 0; j < L; ++ j) for (k = 1; k < Len; ++ k) a[j][i] = (a[j][i] * 10 + line[k] - '0') % Mod[j]; if (temp) for (j = 0; j < L; ++ j) a[j][i] = -a[j][i]; } int res = 0; for (i = 0; i < L; ++ i) for (j = 1; j < Mod[i]; ++ j) { pre[i][0] = 1; for (k = 1; k <= N; ++ k) pre[i][k] = (pre[i][k - 1] * j) % Mod[i]; res = 0; for (k = 0; k <= N; ++ k) res = (res + a[i][k] * pre[i][k]) % Mod[i]; cal[i][j] = res < 0 ? res + Mod[i] : res; } for (i = 1; i <= M; ++ i) if (Judge (i)) Answer[++ C] = i; printf ("%d\n", C); for (i = 1; i <= C; ++ i) printf ("%d\n", Answer[i]); return 0; } int ZlycerQan = Main (); int main (int argc, char *argv[]) {;}
myj 吊打我Orz,xxy 捆起来打我Orz,myl 文化课上天Orz, lrh 姿势水平敲高Orz, hkd 特别胖Orz%%%,cys 智商感人Orz,syl zz专业Orz,我没有学上, 我们未来一片光明