QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#242327 | #554. 预言 | GoatGirl98 | 100 ✓ | 18ms | 3872kb | C++14 | 1.2kb | 2023-11-07 10:37:50 | 2023-11-07 10:37:51 |
Judging History
answer
#include<bits/stdc++.h>
#define fo(i, x, y) for(int i = x, _b = y; i <= _b; i ++)
#define ff(i, x, y) for(int i = x, _b = y; i < _b; i ++)
#define fd(i, x, y) for(int i = x, _b = y; i >= _b; i --)
#define ll long long
#define pp printf
#define hh pp("\n")
using namespace std;
const int N = 2e3 + 5;
#define ui unsigned int
int n; ll m;
ui a[N], b[N];
const ui inf = 4294967295ll;
void qmo(ui *a) {
fd(i, 2 * n, n + 1) if(a[i]) {
fo(j, 1, n) a[i - j] ^= b[j] & a[i];
a[i] = 0;
}
}
ui c[N];
void mul(ui *a, ui *b) {
fo(i, 0, 2 * n) c[i] = 0;
fo(i, 0, n) fo(j, 0, n) c[i + j] ^= a[i] & b[j];
qmo(c);
fo(i, 0, n) a[i] = c[i];
}
ui s[N], x[N];
int main() {
scanf("%d", &n);
fo(i, 1, n) scanf("%u", &a[i]);
fo(i, 1, n) scanf("%u", &b[i]);
scanf("%lld", &m);
s[0] = inf; x[1] = inf;
for(; m; m /= 2, mul(x, x))
if(m & 1) mul(s, x);
ui ans = 0;
fo(i, 1, n) ans ^= s[i] & a[i];
pp("%u\n", ans);
}
/*
test only
-----------------------------------
©著作权归作者所有:来自51CTO博客作者Cold_Chair的原创作品,请联系作者获取转载授权,否则将追究法律责任
【JSOI2017】 预言(广义常系数齐次线性递推)
https://blog.51cto.com/u_16105286/6259948
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 10
Accepted
time: 0ms
memory: 3564kb
input:
1000 3220920311 4292586732 2013265911 4210785274 4271623391 2880417788 1069014421 4254932088 1793848759 1808792466 4294958007 2103304126 2800745466 4119330231 3755932087 3974099315 4194272511 4276221428 3656379287 1610611199 4286283679 4294373371 4290514558 4292802023 4294481342 1534984158 211392711...
output:
2144804347
result:
ok single line: '2144804347'
Test #2:
score: 10
Accepted
time: 1ms
memory: 3840kb
input:
100 4008962975 3145719783 3753573855 1593828991 2898851711 4226637295 4278169035 3204413183 3720853503 3757557451 4154441471 4008968063 2080351567 4174345210 3984579293 4243586542 2952402352 3700907893 4292499643 3178036221 3958873596 3684921839 3065969661 4018076914 2128523059 3221221279 838858223 ...
output:
1272285767
result:
ok single line: '1272285767'
Test #3:
score: 10
Accepted
time: 0ms
memory: 3864kb
input:
100 4025736087 4227717111 4221173228 2147483639 2822566783 4227603951 3145674218 3035608567 3706169343 4294963170 1996340991 4269273853 2147355085 4176974847 3099045583 4126141820 2684202678 4130831780 2113821609 3345939453 3956793341 3754390766 3204178814 1868496507 4154175487 3153059503 2113862887...
output:
4075083590
result:
ok single line: '4075083590'
Test #4:
score: 10
Accepted
time: 15ms
memory: 3864kb
input:
1000 2109208351 1778375541 1065090419 2139716591 754833271 2505959277 3489328495 4269801406 1240921087 4293914607 4294360797 3154092031 1037414359 4021877695 4294901427 1006499286 3069181943 4290199541 4219385759 2070856317 3887320621 267296175 2927098335 3355361277 3747063807 1068990391 2127555053 ...
output:
2222984435
result:
ok single line: '2222984435'
Test #5:
score: 10
Accepted
time: 16ms
memory: 3872kb
input:
1000 4227178396 4227456983 3975904750 2013200383 2835342139 4294836207 872377828 3968843767 3572758391 1761586550 1291659007 4294963611 1602162587 2139085039 3066015615 3758095740 2608328311 2872442853 1475346365 3613391757 4259307509 3622698207 517964671 3973705599 4288674815 2952525743 2146622927 ...
output:
1071602059
result:
ok single line: '1071602059'
Test #6:
score: 10
Accepted
time: 16ms
memory: 3560kb
input:
1000 4275564451 3619100327 3217599927 2030028659 3166699131 4025597891 4257997199 3606837999 3713132495 4292175615 4219182781 4286574581 1809753982 3220077403 4294571007 4267294174 794623479 1404499733 2877291967 4026530775 4286537725 3656383806 2259679911 3959406559 2144362336 2046670171 1677688234...
output:
2329770293
result:
ok single line: '2329770293'
Test #7:
score: 10
Accepted
time: 16ms
memory: 3636kb
input:
1000 2145898303 4018003829 2147220495 1053687359 1036771199 3746162671 3674139759 4276977590 1560212158 4293885879 4271742683 3217025023 2145716222 3885890455 2931470257 3221225340 3186347767 4246199293 1876932253 3556764287 4145826860 3484327551 4269208541 3487038822 2144329663 4160192502 206020497...
output:
163313124
result:
ok single line: '163313124'
Test #8:
score: 10
Accepted
time: 18ms
memory: 3664kb
input:
1000 4294410171 3183419379 3681646297 1002420907 2645819007 4121819883 4269788351 4275961727 3590190238 2076172255 4258248699 1207959295 1291828221 2012463094 4217364463 4227563502 888395729 4289849790 4240179119 3221085167 4294746077 2668358655 4294483438 1709566903 2538435551 3985624830 4294293454...
output:
304868701
result:
ok single line: '304868701'
Test #9:
score: 10
Accepted
time: 18ms
memory: 3612kb
input:
1000 4189394862 2684083095 3220679679 1476018174 4261408575 3216899677 1676657141 3929014249 3372217701 3439173623 4008193855 1811617046 1065336755 4286577903 3200098303 3755980653 3221186291 2947809023 4219469631 903705527 4261141501 1433004693 2145253375 4210016031 3202351069 4292525951 2684276713...
output:
637535013
result:
ok single line: '637535013'
Test #10:
score: 10
Accepted
time: 17ms
memory: 3656kb
input:
1000 2146959167 4023377767 4038521725 1607333854 1568660859 4217161727 3758026011 4210539580 1608233983 3744462458 4294950783 3202579066 2062925101 3904722623 3587637043 3082252283 1073659255 3690458863 4243569439 4210780927 4088386357 3679358975 3724279775 3757834239 3873374047 4294967255 252995045...
output:
1706419192
result:
ok single line: '1706419192'