QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#328497 | #7881. Computational Complexity | Famiglistmo | WA | 55ms | 11060kb | C++17 | 1.4kb | 2024-02-15 20:32:37 | 2024-02-15 20:32:37 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e6+6;
vector<int>vec;
int f[N],g[N];
int T,mod;
int F(int i,int j) {
if(vec[i-1]%j) return 0;
return f[lower_bound(vec.begin(),vec.end(),vec[i-1]/j)-vec.begin()+1];
}
int G(int i,int j) {
if(vec[i-1]%j) return 0;
return g[lower_bound(vec.begin(),vec.end(),vec[i-1]/j)-vec.begin()+1];
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
cin>>f[0]>>g[0]>>T>>mod,f[0]%=mod,g[0]%=mod;
for(int i=1;i<=14;++i)
f[i]=max(i,g[i/2]+g[i/3]+g[i/5]+g[i/7])%mod,
g[i]=max(i,f[i/2]+f[i/3]+f[i/4]+f[i/5])%mod;
for(int i=14;i;--i)
f[i]=(f[i]-f[i-1]+mod)%mod,g[i]=(g[i]-g[i-1]+mod)%mod;
int n=1e15;
for(int i=1;i<=13;++i)
for(int j=i;j<=n;j*=2) for(int k=j;k<=n;k*=3)
for(int l=k;l<=n;l*=5) for(int h=l;h<=n;h*=7)
vec.push_back(h);
sort(vec.begin(),vec.end()),vec.erase(unique(vec.begin(),vec.end()),vec.end());
int sz=vec.size();
for(int i=14;i<=sz;++i)
f[i]=(G(i,2)+G(i,3)+G(i,5)+G(i,7))%mod,
g[i]=(F(i,2)+F(i,3)+F(i,4)+F(i,5))%mod;
for(int i=1;i<=sz;++i) f[i]=(f[i]+f[i-1])%mod,g[i]=(g[i]+g[i-1])%mod;
for(int i=1,x;i<=T;++i)
cin>>x,cout<<f[upper_bound(vec.begin(),vec.end(),x)-vec.begin()]<<" "<<g[upper_bound(vec.begin(),vec.end(),x)-vec.begin()]<<'\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 51ms
memory: 11060kb
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: 50ms
memory: 9588kb
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: -100
Wrong Answer
time: 55ms
memory: 10116kb
input:
2023 2023 10 2023 0 1 2 3 4 5 6 7 8 9
output:
0 0 1 1 2 2 3 3 4 4 5 5 6 7 7 7 8 9 9 10
result:
wrong answer 3rd numbers differ - expected: '0', found: '1'