QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#327981#7881. Computational ComplexitylefyWA 61ms20588kbC++141.5kb2024-02-15 15:52:222024-02-15 15:52:23

Judging History

This is the latest submission verdict.

  • [2024-02-15 15:52:23]
  • Judged
  • Verdict: WA
  • Time: 61ms
  • Memory: 20588kb
  • [2024-02-15 15:52:22]
  • Submitted

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])%mod;
        g[i]=max((ll)i,f[i/2]+f[i/3]+f[i/4]+f[i/5])%mod;
        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";
        if(f[id]<0)f[id]+=mod;
        if(g[id]<0)g[id]+=mod;
        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: 47ms
memory: 20588kb

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: 59ms
memory: 20212kb

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: 61ms
memory: 18664kb

input:

2023 2023 10 2023
0
1
2
3
4
5
6
7
8
9

output:

2023 2023
0 0
0 0
0 0
0 0
0 5
0 6
7 7
8 8
9 9

result:

wrong answer 1st numbers differ - expected: '0', found: '2023'