QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#328376#7881. Computational ComplexitykkioWA 48ms7408kbC++142.3kb2024-02-15 19:46:382024-02-15 19:46:39

Judging History

你现在查看的是最新测评结果

  • [2024-02-15 19:46:39]
  • 评测
  • 测评结果:WA
  • 用时:48ms
  • 内存:7408kb
  • [2024-02-15 19:46:38]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define fir first
#define sec second

#define lson(i) (tr[i].ls)
#define rson(i) (tr[i].rs)

#define FIO(file) freopen(file".in","r",stdin), freopen(file".out","w",stdout)

typedef long long ll;
typedef double db;
typedef long double ldb;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef __int128_t i128;
typedef __uint128_t u128;
ll LIM,m,q,mod;
ll f[15],g[15];
vector<ll> val;
ll fd[1000000],gd[1000000];
inline ll getf(int x){int pos=lower_bound(val.begin(),val.end(),x)-val.begin();if(pos<0||pos>=val.size()||val[pos]!=x)return 0;else return fd[pos];}
inline ll getg(int x){int pos=lower_bound(val.begin(),val.end(),x)-val.begin();if(pos<0||pos>=val.size()||val[pos]!=x)return 0;else return gd[pos];}
int main()
{
    cin>>f[0]>>g[0]>>q>>mod;
    LIM=1e15;
    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;
    }
    val.push_back(0);
    for(ll t=1;t<=min(13ll,LIM);t++)
        for(ll z=t;z<=LIM;z*=2)
            for(ll t=z;t<=LIM;t*=3)
                for(ll z=t;z<=LIM;z*=5)
                    for(ll t=z;t<=LIM;t*=7)
                        val.push_back(t);
    sort(val.begin(),val.end());
    val.resize(unique(val.begin(),val.end())-val.begin());
    for(int i=0;i<val.size();i++)
    {
        if(val[i]<=13){
            if(val[i]==0)fd[i]=f[0],gd[i]=g[0];
            else fd[i]=(f[val[i]]-f[val[i]-1]+mod)%mod,gd[i]=(g[val[i]]-g[val[i]-1]+mod)%mod;
        }
        else 
        {
            fd[i]=(val[i]%2==0?getg(val[i]/2):0)+(val[i]%3==0?getg(val[i]/3):0)+(val[i]%5==0?getg(val[i]/5):0)+(val[i]%7==0?getg(val[i]/7):0);fd[i]%=mod;
            gd[i]=(val[i]%2==0?getf(val[i]/2):0)+(val[i]%3==0?getf(val[i]/3):0)+(val[i]%4==0?getf(val[i]/4):0)+(val[i]%5==0?getf(val[i]/5):0);gd[i]%=mod;
        }
    }
    for(int i=1;i<val.size();i++)
        fd[i]+=fd[i-1],gd[i]+=gd[i-1],fd[i]%=mod,gd[i]%=mod;
    for(int i=1;i<=q;i++)
    {
        ll x;
        cin>>x;
        int pos=upper_bound(val.begin(),val.end(),x)-val.begin()-1;
        //cout<<"!"<<pos<<'\n';
        cout<<fd[pos]<<' '<<gd[pos]<<'\n';
    }
} 

详细

Test #1:

score: 100
Accepted
time: 48ms
memory: 7352kb

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: 48ms
memory: 7304kb

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: 48ms
memory: 7408kb

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'