QOJ.ac
QOJ
The 2nd Universal Cup Finals is coming! Check out our event page, schedule, and competition rules!
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#304639 | #7881. Computational Complexity | ucup-team134 | TL | 2ms | 3924kb | C++17 | 673b | 2024-01-13 22:23:39 | 2024-01-13 22:23:39 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll M,f0,g0;
map<ll,ll> f,g;
ll lim=1e15;
ll G(ll m);
ll F(ll m){
if(m==0)return f0;
if(!f.count(m)){
ll val=max(m,G(m/2)+G(m/3)+G(m/5)+G(m/7));
if(val>=lim)val=lim+val%lim;
return f[m]=val;
}
return f[m];
}
ll G(ll m){
if(m==0)return g0;
if(!g.count(m)){
ll val=max(m,F(m/2)+F(m/3)+F(m/4)+F(m/5));
if(val>=lim)val=lim+val%lim;
return g[m]=val;
}
return g[m];
}
int main(){
int t;
scanf("%lld %lld %i %lld",&f0,&g0,&t,&M);
lim=(lim/M+1)*M;
while(t--){
ll m;
scanf("%lld",&m);
printf("%lld %lld\n",F(m)%M,G(m)%M);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 3924kb
input:
1958 920 10 100000000000 0 1 2 3 10 100 200 1000 19580920 20232023
output:
1958 920 3680 7832 10592 9554 17504 11276 50294 64826 784112 893714 1894550 1905470 12057866 12979424 71481494756 48626708512 28127864908 7251681354
result:
ok 20 numbers
Test #2:
score: 0
Accepted
time: 0ms
memory: 3852kb
input:
0 0 10 100000000000 0 1 2 3 4 10 20 30 40 100
output:
0 0 1 1 2 2 3 3 4 4 11 12 25 26 41 41 55 58 162 172
result:
ok 20 numbers
Test #3:
score: 0
Accepted
time: 0ms
memory: 3852kb
input:
2023 2023 10 2023 0 1 2 3 4 5 6 7 8 9
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
result:
ok 20 numbers
Test #4:
score: -100
Time Limit Exceeded
input:
36092 30559 2149 729566623185 909730017626 961811467628 978809456383 494310140318 760462959632 726343527430 220697276132 366336227300 456813204361 569783542145 13854148170 51526515764 564416233246 876430686824 862897449267 956440673661 512777546436 728860125927 799238602356 978766770799 47962348351 ...
output:
192287632545 510282654057 513694515018 658644741565 90751152870 6088748556 138070013247 301112114677 224113421002 105290451187 630454127249 196841848259 546918129568 526274849982 226761501362 157889210040 135623074930 620463814922 78467045157 602244472172 51639549042 411354142414 329188915935 306494...