發布時間: Feb. 8, 2021, 12:10 a.m. 最後更新時間: Sept. 14, 2023, 11 p.m. 時間限制: 1000ms 記憶體限制: 128M
今天你拿到了$N(1\leq N\leq 50)$個二次函數和一個整數$C(1\leq C\leq 10^9)$,你發現這些函數很特別,他們的係數存在著某種規律。假設第$i(1\leq i\leq N)$個二次函數可以被表示成
$$\Huge{\Gamma _i:y=a_i(x-b_i)^2}$$
那麼,你發現到如果先用下面代碼算出$\text{B[i]}$,再把$\text{B[i]}$帶入下面的式子就可以算出$b_i$了呢!注意下面代碼中$\text{p[i]}$是指第$i - 1$個質數,$\text{C}$是給定的一個整數,$\text{a[i]}$表示$a_i$
#define int long long
const int MOD = 1000000007, MAXN = 55;
int B[MAXN + 1], a[MAXN + 1], N, p[5 * MAXN] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583};
int bool1[30] = {0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1};
int bool2[30] = {0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1};
int func(int ai, int C, int BB) {
int owo = (C & 13) ^ (C << 13) ^ (C >> 16) ^ (C << 14) ^ (C >> 17) ^ (C << 3) ^ (C >> 6) ^ ai;
int ouo = (owo & 880301) ^ (owo >> 11) ^ (owo << 11) ^ (owo >> 12) ^ (owo << 12) ^ (ai >> 13) ^ (ai << 13);
int oao = (owo & 110029) ^ (owo << 21) ^ (owo << 14) ^ (owo >> 11) ^ (owo >> 9);
int ovo = (BB ^ C ^ owo ^ ouo ^ oao ^ ai);
for (int i = 0; i < 30; i++)
if (bool1[i])
ovo ^= (ovo << i);
for (int i = 0; i < 30; i++)
if (bool2[i])
ovo ^= (ovo >> i);
for (int i = 0; i < 30; i++)
if (bool1[i] ^ bool2[i])
ovo ^= p[i];
for (int i = 0; i < 30; i++)
if (bool1[i] & bool2[(30 ^ i) % 30])
ovo ^= p[i << 1];
for (int i = 0; i < 30; i++)
if (bool1[(30 ^ i) % 30] & bool2[i])
ovo ^= p[i << 2];
for (int i = 0; i < 30; i++)
if (bool1[(30 ^ i) % 30] & bool2[(30 ^ i) % 30])
ovo ^= p[(i ^ MAXN) % MAXN];
return ovo % 1000000001;
}
void generate(int N, int C) {
B[0] = N;
B[1] = func(a[1], C, B[0]);
for (int i = 2; i <= N; i++) {
B[i] = func(a[i], B[i - 1], B[i - 2]);
}
}
$$\Huge{b_i = \frac{\text{B[i]}}{\prod_{j = 1}^i \text{B[j]}}}$$
那麼,因為我很好奇,所以想請教你,在保證任意三個函數不共交點時,這些函數在二維歐氏平面上會有幾個交點?
第一行有兩個整數$N, C(1\leq N\leq 50, 1\leq C\leq 10^9)$,接下來有$N$行
接下來$N$行中的第$i$行有一個整數$a_i(-10^9\leq a_i\leq 10^9)$,保證$a_i$隨機,$b_i$可以用上述方法求出,保證所有$a_i$相異且不為$0$
輸出一行一個整數,表示這些函數有幾個交點
47 1849264 -432972854 640301083 292725442 -255553005 -319082457 -759209662 104019818 2371046 988443054 -378106036 -631057001 39695304 -915461311 355055356 -648708143 -270305004 852173402 702904149 195468674 -614997414 -629765509 270964878 -913132163 846340146 -699865328 -928170853 932637978 156335371 949058694 -886081280 223997563 -18813272 -721587817 -945823486 597578433 -487315010 -7764834 285916007 -885093759 -358606166 685743745 -456632656 274483564 243364970 -928318167 -981758736 638246174
1062