QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#304635 | #7881. Computational Complexity | ucup-team134 | WA | 2ms | 4016kb | C++17 | 534b | 2024-01-13 22:18:57 | 2024-01-13 22:18:58 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll M,f0,g0;
map<ll,ll> f,g;
ll G(ll m);
ll F(ll m){
if(m==0)return f0;
if(!f.count(m)){
return f[m]=(G(m/2)+G(m/3)+G(m/5)+G(m/7))%M;
}
return f[m];
}
ll G(ll m){
if(m==0)return g0;
if(!g.count(m)){
return g[m]=(F(m/2)+F(m/3)+F(m/4)+F(m/5))%M;
}
return g[m];
}
int main(){
int t;
scanf("%lld %lld %i %lld",&f0,&g0,&t,&M);
while(t--){
ll m;
scanf("%lld",&m);
printf("%lld %lld\n",F(m),G(m));
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 4016kb
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: -100
Wrong Answer
time: 0ms
memory: 3848kb
input:
0 0 10 100000000000 0 1 2 3 4 10 20 30 40 100
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
result:
wrong answer 3rd numbers differ - expected: '1', found: '0'