QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#327831 | #7881. Computational Complexity | liujiameng | WA | 159ms | 26356kb | C++14 | 1.3kb | 2024-02-15 14:53:59 | 2024-02-15 14:53:59 |
Judging History
answer
//test
#include<bits/stdc++.h>
using namespace std;
long long N=1e15;
long long f[15],g[15],mod;
map<long long,int>mp;
map<long long,long long>cf,cg;
void suan(long long x){
cf[x]=((x%2?0:cg[x/2])+(x%3?0:cg[x/3])+(x%5?0:cg[x/5])+(x%7?0:cg[x/7]))%mod;
cg[x]=((x%2?0:cf[x/2])+(x%3?0:cf[x/3])+(x%4?0:cf[x/4])+(x%5?0:cf[x/5]))%mod;
}
long long a1[1000005],a2f[1000005],a2g[1000005];
int main(){
int T;
scanf("%lld%lld%d%lld",&f[0],&g[0],&T,&mod);
for(int i=1;i<=13;++i){
f[i]=max(0ll+i,g[i/2]+g[i/3]+g[i/5]+g[i/7]);
g[i]=max(0ll+i,f[i/2]+f[i/3]+f[i/4]+f[i/5]);
}
int tt=0;
for(int i=1;i<=13;++i){
cf[i]=(f[i]-f[i-1]%mod+mod)%mod;cg[i]=(g[i]-g[i-1]%mod+mod)%mod;
for(long long c1=1;i*c1<=N;c1*=2)
for(long long c2=1;i*c1*c2<=N;c2*=3)
for(long long c3=1;i*c1*c2*c3<=N;c3*=5)
for(long long c4=1;i*c1*c2*c3*c4<=N;c4*=7){
long long x=i*c1*c2*c3*c4;
if(!mp[x])mp[x]=++tt;
}
}
for(auto pi:mp)if(pi.first>13)suan(pi.first);
long long hf=f[0],hg=g[0];
int zg=0;
for(auto pi:mp){
long long x=pi.first;
a1[++zg]=x;
hf=(hf+cf[x])%mod,hg=(hg+cg[x])%mod;
a2f[zg]=hf,a2g[zg]=hg;
}
while(T--){
long long m;
scanf("%lld",&m);
int wz=upper_bound(a1+1,a1+zg+1,m)-a1-1;
printf("%lld %lld\n",a2f[wz],a2g[wz]);
}
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 159ms
memory: 26356kb
input:
1958 920 10 100000000000 0 1 2 3 10 100 200 1000 19580920 20232023
output:
0 0 3680 7832 10592 9554 17504 11276 50294 64826 784112 893714 1894550 1905470 12057866 12979424 71481494756 48626708512 28127864908 7251681354
result:
wrong answer 1st numbers differ - expected: '1958', found: '0'