QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#797101#6226. 取石子propane0 359ms3860kbC++20974b2024-12-02 16:33:062024-12-02 16:33:06

Judging History

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

  • [2024-12-02 16:33:06]
  • 评测
  • 测评结果:0
  • 用时:359ms
  • 内存:3860kb
  • [2024-12-02 16:33:06]
  • 提交

answer

#include<iostream>
#include<cstring>
#include<vector>
#include<unordered_map>
#include<algorithm>
using namespace std;
using LL = long long;
LL f[88];

unordered_map<LL, LL> mp;
LL n, k;
int l;

LL dp(LL n){
    if (n <= k) return 0;
    if (mp.contains(n)) return mp[n];
    int r = upper_bound(f + 1, f + 88, n) - f - 1;
    LL ans = r - l + 1;
    for(int i = l; i + 1 <= r; i++){
        ans += dp(f[i + 1] - f[i] - 1);
    }
    ans += dp(n - f[r]);
    return mp[n] = ans;
}

int main(){

#ifdef LOCAL
    freopen("data.in", "r", stdin);
    freopen("data.out", "w", stdout);
#endif

    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(0);

    f[0] = f[1] = 1;
    for(int i = 2; i < 88; i++){
        f[i] = f[i - 1] + f[i - 2];
    }

    int T;
    cin >> T;
    while(T--){
        mp.clear();
        cin >> k >> n;
        l = upper_bound(f + 1, f + 88, k) - f;
        cout << n - dp(n) << '\n';
    }

}

详细


Pretests


Final Tests

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3860kb

input:

499
336 455
5 9
420 424
35 57
9 424
55 71
38 414
64 346
42 480
18 212
37 249
82 488
6 190
75 165
51 272
13 37
29 143
44 195
71 175
149 180
42 245
62 376
193 285
47 207
128 145
5 209
281 329
9 437
258 296
2 31
70 240
268 356
21 93
147 180
79 115
63 106
112 443
219 305
332 476
47 450
134 290
51 89
243...

output:

454
8
424
56
386
71
406
342
470
201
244
482
163
163
267
35
139
192
173
180
240
372
284
203
144
179
329
398
296
20
237
356
90
180
114
105
440
304
475
441
288
87
388
249
10
343
221
238
180
56
181
22
241
425
304
136
30
36
226
457
308
340
131
120
413
411
145
318
437
95
296
152
128
414
272
377
400
99
195...

result:

wrong answer 1st lines differ - expected: '453', found: '454'

Test #2:

score: 0
Wrong Answer
time: 20ms
memory: 3560kb

input:

49875
14399 29607
6224 29914
1106 26641
17 26569
6365 25718
27 4637
1618 2714
33573 40913
35563 36097
8973 28132
5673 25161
17636 34907
6000 10087
4467 7440
8334 49937
259 20572
6268 28505
6401 15802
12571 13234
23041 27538
2493 47406
5802 10423
11962 30757
3300 3837
8350 20422
225 16103
23645 34285...

output:

29605
29909
26622
25089
25714
4478
2713
40913
36097
28130
25157
34905
10086
7439
49932
20509
28501
15800
13234
27538
47385
10422
30755
3837
20420
16023
34284
14144
11944
3086
26305
4188
45878
6745
2565
6584
41137
24162
24496
3582
20251
1597
1769
42298
36850
39561
1568
19249
5958
29388
18797
41588
42...

result:

wrong answer 1st lines differ - expected: '29604', found: '29605'

Test #3:

score: 0
Wrong Answer
time: 32ms
memory: 3560kb

input:

94256
53191 66970
85363 96281
23759 25693
28568 43227
27 31316
10224 32226
9111 25249
16987 19389
15006 30353
9523 59244
42546 55606
6039 6830
5609 54488
2509 12330
29480 70960
14785 65267
60831 91903
281 18175
31994 76610
3582 9689
7665 34764
12673 18964
16448 22115
5748 30321
33618 49834
18843 244...

output:

66970
96281
25693
43226
30238
32223
25247
19388
30351
59238
55605
6829
54479
12325
70959
65263
91902
18119
76608
9687
34761
18963
22114
30316
49833
24426
70060
40153
56260
57055
14262
45340
15708
14218
55633
98632
52712
24036
98750
39749
89562
80982
18907
48684
22462
41207
97045
74801
91012
49045
98...

result:

wrong answer 1st lines differ - expected: '66969', found: '66970'

Test #4:

score: 0
Wrong Answer
time: 0ms
memory: 3656kb

input:

3
34279 810634
918771 1021048
25 42120

output:

810614
1021048
40670

result:

wrong answer 1st lines differ - expected: '810613', found: '810614'

Test #5:

score: 0
Wrong Answer
time: 0ms
memory: 3556kb

input:

3
690379 1982172
417599 1708659
1717080 2863950

output:

1982170
1708656
2863949

result:

wrong answer 1st lines differ - expected: '1982169', found: '1982170'

Test #6:

score: 0
Wrong Answer
time: 36ms
memory: 3792kb

input:

944
1 343954967570505156
1 84731075985818925
1 138311144113583007
1 104547054550584433
1 693241347397247084
1 472332079344024358
1 156793474620214247
1 850344749061699637
1 803512580085688163
1 310836022836048564
1 495053169351075063
1 82844446500137324
1 178945557527795821
1 216483389996708327
1 59...

output:

131379107012565125
32364391123232826
52830156028503762
39933421414633891
264794632298974934
180414800332505167
59889778090727832
324802791986569006
306914495204610982
118728795795532068
189093484453752949
31643762783880188
68351120839818397
82689296978943594
226609373538521525
31210098343021365
1747...

result:

wrong answer 4th lines differ - expected: '39933421414633890', found: '39933421414633891'

Test #7:

score: 0
Time Limit Exceeded

input:

91665
1 367380666905152293
1 182005789689897190
1 623096247285159354
1 671594325644512277
1 742160204799780654
1 794275980040994924
1 74354650304567324
1 911166360819358930
1 764757676441890048
1 752269248988307295
1 955093740058796962
1 747803753737785010
1 404138290206507311
1 181396406609700806
1...

output:

140326927948164534
69520025512275543
238001588200421480
256526205744638560
283479973135933361
303386427928026962
28400949194731997
348034580427444623
292111439243407250
287341284422175938
364813346260203446
285635617013077652
154367090703617033
69287261887809627
23433513534972568
245586033973105615
...

result:


Test #8:

score: 0
Wrong Answer
time: 4ms
memory: 3604kb

input:

911
78374152724567593 983112666946547816
753553157811176669 788891899819251115
33856693441045857 281513707367405940
458492126183900287 469318687938414816
20297113357777935 33378284552002778
10115955709864055 787679629225677540
17150232293760847 102828488233093971
112680441700253174 12938526751175947...

output:

983112666946547805
788891899819251115
281513707367405932
469318687938414816
33378284552002777
787679629225677477
102828488233093966
129385267511759477
393578058742371564
710310834833243827
96936676611661624
735136776039311810
198814605441753840
180714195277663472
595056197625354638
81570251109792082...

result:

wrong answer 1st lines differ - expected: '983112666946547804', found: '983112666946547805'

Test #9:

score: 0
Wrong Answer
time: 359ms
memory: 3624kb

input:

98295
873150664261731328 951581568702046682
56 727890463110977051
859978062141145093 947945138127019948
330253590080540990 768615565614466064
13256179404231692 95760438247048090
638707615934448347 792288571729874417
54711657924896980 847301161318887407
856185831773980409 893587664123567425
312798854...

output:

951581568702046682
718314614598993503
947945138127019948
768615565614466062
95760438247048083
792288571729874416
847301161318887391
893587664123567425
537497297873269824
9294212206362215
658682178594527623
905480424268227149
325786925372156417
562180168829403837
53899373768465926
713229827374765300
...

result:

wrong answer 1st lines differ - expected: '951581568702046681', found: '951581568702046682'

Test #10:

score: 0
Wrong Answer
time: 340ms
memory: 3508kb

input:

91640
405786310369032226 553800146036810186
84 288402474700211717
19845023439645913 392170479523345754
597697212044203925 702078911619194971
11204130783741609 13290697100124817
23 484543424049569697
559463321235963921 601484656718057819
227796568880241875 992739563025444500
156735875816653837 901104...

output:

553800146036810185
284608362058033390
392170479523345735
702078911619194970
13290697100124817
467854850303592543
601484656718057819
992739563025444496
901104214479350061
48697612993165860
734901520058359732
279043494845859134
114370108376756252
853502730432930235
262119937602158136
18879980688626615...

result:

wrong answer 1st lines differ - expected: '553800146036810184', found: '553800146036810185'