QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#327975 | #7881. Computational Complexity | lefy | WA | 60ms | 11268kb | C++14 | 1.5kb | 2024-02-15 15:50:27 | 2024-02-15 15:50:27 |
Judging History
answer
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e6+10;
const ll Max=1e15;
ll f[N],g[N],F[N],G[N],mod,L[N],tot;
ll getg(ll x,int y){
if(x%y)return 0;
// if(x==14)cout<<y<<"\n";
int id=lower_bound(L+1,L+1+tot,x/y)-L;
return G[id];
}
ll getf(ll x,int y){
if(x%y)return 0;
int id=lower_bound(L+1,L+1+tot,x/y)-L;
return F[id];
}
void init(){
for(int i=1;i<=13;i++){
f[i]=max((ll)i,g[i/2]+g[i/3]+g[i/5]+g[i/7]);
g[i]=max((ll)i,f[i/2]+f[i/3]+f[i/4]+f[i/5]);
F[i]=f[i]-f[i-1],G[i]=g[i]-g[i-1];
// cout<<f[i]<<" "<<g[i]<<"\n";
}
set<ll>st;
for(int i=1;i<=13;i++)for(ll i2=1;(ll)i*i2<=Max;i2<<=1)for(ll i3=1;(ll)i*i2*i3<=Max;i3*=3)
for(ll i5=1;(ll)i*i2*i3*i5<=Max;i5*=5)for(ll i7=1;(ll)i*i2*i3*i5*i7<=Max;i7*=7){
st.insert((ll)i*i2*i3*i5*i7);
}
// cout<<"*";
for(ll x:st){
L[++tot]=x;if(x<=13)continue;
// if(x<=20)cout<<x<<"\n";
F[tot]=(getg(x,2)+getg(x,3)+getg(x,5)+getg(x,7))%mod;f[tot]=(f[tot-1]+F[tot])%mod;
G[tot]=(getf(x,2)+getf(x,3)+getf(x,4)+getf(x,5))%mod;g[tot]=(g[tot-1]+G[tot])%mod;
}
}
int main() {
int t;
scanf("%lld%lld%d%lld",&f[0],&g[0],&t,&mod);
init();
while(t--){
ll x;scanf("%lld",&x);
int id=upper_bound(L+1,L+1+tot,x)-L-1;
// cout<<F[id]<<"\n";
printf("%lld %lld\n",f[id],g[id]);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 54ms
memory: 11268kb
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: 60ms
memory: 11016kb
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: 52ms
memory: 11072kb
input:
2023 2023 10 2023 0 1 2 3 4 5 6 7 8 9
output:
2023 2023 8092 8092 14161 14161 20230 20230 26299 32368 32368 38437 44506 50575 50575 50575 62713 62713 68782 68782
result:
wrong answer 1st numbers differ - expected: '0', found: '2023'