QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#5866 | #554. 预言 | Qingyu✨ | 100 ✓ | 26ms | 3824kb | C++98 | 1.5kb | 2021-01-26 00:22:17 | 2021-12-19 07:05:05 |
Judging History
answer
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const unsigned LOG = 60;
struct LinearRec {
int n;
vector<unsigned> first, trans;
vector<vector<unsigned> > bin;
vector<unsigned> add(vector<unsigned> &a, vector<unsigned> &b) {
vector<unsigned> result(n * 2 + 1, 0);
for (int i = 0; i <= n; ++i) {
for (int j = 0; j <= n; ++j) {
result[i + j] ^= a[i] & b[j];
}
}
for (int i = 2 * n; i > n; --i) {
for (int j = 0; j < n; ++j) {
result[i - 1 - j] ^= result[i] & trans[j];
}
result[i] = 0;
}
result.erase(result.begin() + n + 1, result.end());
return result;
}
LinearRec(vector<unsigned> &first, vector<unsigned> &trans):first(first), trans(trans) {
n = first.size();
vector<unsigned> a(n + 1, 0);
a[1] = ~0u;
bin.push_back(a);
for (int i = 1; i < LOG; ++i) {
bin.push_back(add(bin[i - 1], bin[i - 1]));
}
}
unsigned calc(long long k) {
vector<unsigned> a(n + 1, 0);
a[0] = ~0u;
for (int i = 0; i < LOG; ++i) {
if (k >> i & 1) {
a = add(a, bin[i]);
}
}
unsigned ret = 0;
for (int i = 0; i < n; ++i) {
ret = ret ^ (a[i + 1] & first[i]);
}
return ret;
}
};
int n;
long long t;
int main() {
scanf("%d", &n);
vector<unsigned> a(n), b(n);
for (int i = 0; i < n; ++i) {
scanf("%u", &a[i]);
}
for (int i = 0; i < n; ++i) {
scanf("%u", &b[i]);
}
LinearRec f(a, b);
cin >> t;
printf("%u\n", f.calc(t));
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 10
Accepted
time: 20ms
memory: 3684kb
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 2113927115 3867092981 2934398669 987198462 2122186478 1609546655 3757551355 2684349436 3221222399 4227586799 2071330755 3214671772 474953595 3891994507 1459353077 3563289391 3187408669 4157816317 2077194143 38...
output:
2144804347
result:
ok single line: '2144804347'
Test #2:
score: 10
Accepted
time: 1ms
memory: 3700kb
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 4291284845 4263759869 2147467247 2146735935 4192173304 603877276 4261338109 3941590371 1979709159 805306351 2949644246 4159159998 4194303654 2883059703 3758096059 3208642101 4024073143 4109303679 1867...
output:
1272285767
result:
ok single line: '1272285767'
Test #3:
score: 10
Accepted
time: 2ms
memory: 3628kb
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 3202350965 4151498111 4286267374 2139002811 4221516286 2885578749 1607319549 4025806823 4072598871 4026236911 4194298839 1877458620 3119505911 1809317783 3745513207 4026531383 3755900405 3820937207 1...
output:
4075083590
result:
ok single line: '4075083590'
Test #4:
score: 10
Accepted
time: 20ms
memory: 3764kb
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 4292787544 3682197155 3012531975 905884045 4282867198 2407233401 3082288861 4152094702 4026384371 3874356332 3611294961 4276328382 3917209587 3780206071 1593818079 4294863983 1073143795 4160682939 133...
output:
2222984435
result:
ok single line: '2222984435'
Test #5:
score: 10
Accepted
time: 24ms
memory: 3736kb
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 488505205 4026520062 4294750184 4267652795 4160567710 2918678517 3756898165 1071508157 3680435519 3724216263 4194285543 2137337328 1040036831 1809317822 3585537903 4023631834 3690986581 1467569879 650...
output:
1071602059
result:
ok single line: '1071602059'
Test #6:
score: 10
Accepted
time: 20ms
memory: 3816kb
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 1807729405 3853512703 2139074031 4020975534 2415885818 2813296093 3925310973 4278175583 2096889854 462945263 2146133941 3622305654 2091118206 3923179005 3556438011 1006632957 4160733174 1771044731 18...
output:
2329770293
result:
ok single line: '2329770293'
Test #7:
score: 10
Accepted
time: 23ms
memory: 3680kb
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 2060204975 3220700660 4210947299 3015677870 2776347931 4259797502 662642488 2515377148 4286312446 2080307835 3086579822 3681550067 4293646204 2516571115 3822287551 1589504990 1874853887 3455565308 4293393399 1...
output:
163313124
result:
ok single line: '163313124'
Test #8:
score: 10
Accepted
time: 26ms
memory: 3748kb
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 3915907021 4294868927 4282989637 4272797631 4114317004 2934382564 2077912765 1941883131 3487402703 4293914601 2950163894 2951609854 3837787583 3955735262 2405807415 3743378430 771354187 3757309887 18...
output:
304868701
result:
ok single line: '304868701'
Test #9:
score: 10
Accepted
time: 24ms
memory: 3824kb
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 3756834537 3758092796 3489578730 4283937459 3472714540 2361098237 4289247101 3150966719 4294596398 4237500375 2813755365 3194974206 4252547935 2874513341 3216998317 3355360715 4227582381 4278052091 2...
output:
637535013
result:
ok single line: '637535013'
Test #10:
score: 10
Accepted
time: 24ms
memory: 3784kb
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 2529950455 3938439164 4020563779 671057903 4160206271 4293349226 3984423897 920612789 3739436924 4247250911 2013134330 3749624503 4289386234 2113854714 2344845311 905928689 3170106365 4292869055 2088717167 402...
output:
1706419192
result:
ok single line: '1706419192'