QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#328455#7881. Computational ComplexityCharlieVinnieWA 209ms14376kbC++171.9kb2024-02-15 20:14:372024-02-15 20:14:37

Judging History

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

  • [2024-02-15 20:14:37]
  • 评测
  • 测评结果:WA
  • 用时:209ms
  • 内存:14376kb
  • [2024-02-15 20:14:37]
  • 提交

answer

#include "bits/stdc++.h"
#ifdef DEBUG
#include "PrettyDebug.hpp"
#else
#define debug(...) [](auto...){}(__VA_ARGS__)
#define debuga(...) [](auto...){}(__VA_ARGS__)
#endif
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Rev(i,a,b) for(int i=a;i>=b;i--)
#define Fin(file) freopen(file,"r",stdin)
#define Fout(file) freopen(file,"w",stdout)
using namespace std; typedef long long ll;
constexpr ll LIM=1e15;
ll mod; map<ll,ll> F,G;
void ck(ll& x,ll y) { x+=y-mod; x+=(x>>31)&mod; }
signed main(){
    atexit([](){cerr<<"Time = "<<clock()<<" ms"<<endl;});
    ios::sync_with_stdio(0); cin.tie(0);
    ll f0,g0,T; cin>>f0>>g0>>T>>mod;
    ll f[15]={f0},g[15]={g0}; F[0]=f0; G[0]=g0;
    For(i,1,14){
        f[i]=max(1ll*i,g[i/2]+g[i/3]+g[i/5]+g[i/7]);
        g[i]=max(1ll*i,f[i/2]+f[i/3]+f[i/4]+f[i/5]);
        F[i]=(f[i]-f[i-1]+mod)%mod; G[i]=(g[i]-g[i-1]+mod)%mod;
    }
    For(i,1,14){
        for(ll x2=i;x2<=LIM;x2*=2){
            for(ll x3=x2;x3<=LIM;x3*=3){
                for(ll x4=x3;x4<=LIM;x4*=5){
                    for(ll x5=x4;x5<=LIM;x5*=7){
                        if(F.count(x5)) continue;
                        #pragma GCC unroll(4)
                        for(int o:{2,3,5,7}) if(x5%o==0) ck(F[x5],G[x5/o]);
                        #pragma GCC unroll(4)
                        for(int o:{2,3,4,5}) if(x5%o==0) ck(G[x5],F[x5/o]);
                    }
                }
            }
        }
    }
    ll lst=0; for(auto& [x,y]:F) ck(y,lst),lst=y;
       lst=0; for(auto& [x,y]:G) ck(y,lst),lst=y;
    while(T--){
        ll x; cin>>x; cout<<(--F.upper_bound(x))->second<<' '<<(--G.upper_bound(x))->second<<'\n';
    }
    return 0;
}

// CONTINUE, NON-STOPPING, FOR CHARLIEY
// START TYPING IF YOU DON'T KNOW WHAT TO DO
// STOP TYPING IF YOU DON'T KNOW WHAT YOU'RE DOING

// Started Coding On: February 15 Thu, 18 : 37 : 30

詳細信息

Test #1:

score: 100
Accepted
time: 209ms
memory: 14224kb

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: 194ms
memory: 14232kb

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: 0
Accepted
time: 192ms
memory: 14236kb

input:

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

output:

0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0

result:

ok 20 numbers

Test #4:

score: -100
Wrong Answer
time: 194ms
memory: 14376kb

input:

36092 30559 2149 729566623185
909730017626
961811467628
978809456383
494310140318
760462959632
726343527430
220697276132
366336227300
456813204361
569783542145
13854148170
51526515764
564416233246
876430686824
862897449267
956440673661
512777546436
728860125927
799238602356
978766770799
47962348351
...

output:

-13141969946868047 -13808986844112465
-14121441233175477 -14835812155790630
-14505812207583481 -15236741863109210
-5812865084975627 -6116188331803518
-10353282744302050 -10885117039163796
-9786190193778613 -10288109741790247
-1744594147297379 -1835276994169090
-3783513548766970 -3979485648841843
-51...

result:

wrong answer 1st numbers differ - expected: '192287632545', found: '-13141969946868047'