QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#335423 | #7881. Computational Complexity | AFewSuns | WA | 34ms | 5060kb | C++14 | 2.3kb | 2024-02-23 12:55:59 | 2024-02-23 12:55:59 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
namespace my_std{
#define ll long long
#define bl bool
ll my_pow(ll a,ll b,ll mod){
ll res=1;
if(!b) return 1;
while(b){
if(b&1) res=(res*a)%mod;
a=(a*a)%mod;
b>>=1;
}
return res;
}
ll qpow(ll a,ll b){
ll res=1;
if(!b) return 1;
while(b){
if(b&1) res*=a;
a*=a;
b>>=1;
}
return res;
}
#define db double
#define pf printf
#define pc putchar
#define fr(i,x,y) for(register ll i=(x);i<=(y);i++)
#define pfr(i,x,y) for(register ll i=(x);i>=(y);i--)
#define go(u) for(ll i=head[u];i;i=e[i].nxt)
#define enter pc('\n')
#define space pc(' ')
#define fir first
#define sec second
#define MP make_pair
#define il inline
#define inf 8e18
#define random(x) rand()*rand()%(x)
#define inv(a,mod) my_pow((a),(mod-2),(mod))
il ll read(){
ll sum=0,f=1;
char ch=0;
while(!isdigit(ch)){
if(ch=='-') f=-1;
ch=getchar();
}
while(isdigit(ch)){
sum=sum*10+(ch^48);
ch=getchar();
}
return sum*f;
}
il void write(ll x){
if(x<0){
x=-x;
pc('-');
}
if(x>9) write(x/10);
pc(x%10+'0');
}
il void writeln(ll x){
write(x);
enter;
}
il void writesp(ll x){
write(x);
space;
}
}
using namespace my_std;
vector<ll> lsh,f,g;
ll lim=1e15,t,mod;
il ll calcf(ll x){
ll pos=upper_bound(lsh.begin(),lsh.end(),x)-lsh.begin()-1;
return f[pos];
}
il ll calcg(ll x){
ll pos=upper_bound(lsh.begin(),lsh.end(),x)-lsh.begin()-1;
return g[pos];
}
int main(){
lsh.push_back(0);
for(ll a=1;a<=lim;a*=2){
for(ll b=1;a*b<=lim;b*=3){
for(ll c=1;a*b*c<=lim;c*=5){
for(ll d=1;a*b*c*d<=lim;d*=7){
lsh.push_back(a*b*c*d);
if(a*b*c*d*11<=lim) lsh.push_back(a*b*c*d*11);
if(a*b*c*d*13<=lim) lsh.push_back(a*b*c*d*13);
}
}
}
}
sort(lsh.begin(),lsh.end());
f.resize((ll)lsh.size());
g.resize((ll)lsh.size());
f[0]=read();
g[0]=read();
t=read();
mod=read();
fr(i,1,(ll)lsh.size()-1){
ll x=lsh[i];
f[i]=(calcg(x/2)+calcg(x/3)+calcg(x/5)+calcg(x/7))%mod;
g[i]=(calcf(x/2)+calcf(x/3)+calcf(x/4)+calcf(x/5))%mod;
if(x<=13){
f[i]=max(f[i],x);
g[i]=max(g[i],x);
}
}
while(t--){
ll x=read();
writesp(calcf(x)%mod);
writeln(calcg(x)%mod);
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 30ms
memory: 5044kb
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: 34ms
memory: 5060kb
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: 33ms
memory: 5040kb
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'