QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#622480#8021. Sum of LogOkuchiriAC ✓288ms3696kbC++201.3kb2024-10-08 22:04:452024-10-08 22:04:45

Judging History

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

  • [2024-10-08 22:04:45]
  • 评测
  • 测评结果:AC
  • 用时:288ms
  • 内存:3696kb
  • [2024-10-08 22:04:45]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
ll f[40][2][2][2];
ll num1[40],tot,num2[40];
ll dfs(ll now,ll small1,ll small2,ll zero)
{
    if(now==0)return 1;
    if(f[now][small1][small2][zero]!=-1)return f[now][small1][small2][zero];
    ll res=0;
    ll mx=num1[now],my=num2[now];
    if(small1)mx=1;
    if(small2)my=1;
    for(int i=0;i<=mx;i++)
    {
        for(int j=0;j<=my;j++)
        {
            if(i&j)continue;
            ll k=1;
            if(zero&&(i||j))k=now;
            res=(res+dfs(now-1,small1||(i<num1[now]),small2||(j<num2[now]),zero&&(i==0)&&(j==0))*k%mod)%mod;
        }
    }
    f[now][small1][small2][zero]=res;
    return res;
}
void work()
{
    memset(f,-1,sizeof(f));
    memset(num1,0,sizeof(num1));
    memset(num2,0,sizeof(num2));
    tot=0;
    ll x,y;
    cin>>x>>y;
    if(x<y)swap(x,y);
    if(x==0&&y==0)
    {
        cout<<"0\n";
        return;
    }
    while(x)
    {
        tot++;
        num1[tot]=x%2;
        num2[tot]=y%2;
        x=x/2;
        y=y/2;
    }
    cout<<(dfs(tot,0,0,1)-1+mod)%mod<<'\n';
}
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int T=1;
    cin>>T;
    while(T--)
    {
        work();
    }
}

这程序好像有点Bug,我给组数据试试?

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3684kb

input:

3
3 3
19 26
8 17

output:

14
814
278

result:

ok 3 lines

Test #2:

score: 0
Accepted
time: 1ms
memory: 3688kb

input:

100
208 852
79 665
184 646
363 936
66 902
456 650
456 744
93 515
63 962
455 662
53 732
163 702
408 920
172 506
214 763
356 538
490 744
151 995
180 939
158 534
145 555
220 920
281 882
187 564
238 628
699 142
645 413
886 426
709 473
977 458
824 329
765 431
609 301
687 70
606 262
560 138
946 123
523 37...

output:

197466
81563
135448
309151
101055
256847
287007
64991
99331
262159
70186
137640
326697
92671
165650
171123
294189
188816
200496
98224
99086
217206
251283
116228
149016
124628
239153
323921
282599
352035
267703
281537
182099
78585
157695
96088
149631
163867
42033
125796
294241
302317
155688
140360
31...

result:

ok 100 lines

Test #3:

score: 0
Accepted
time: 0ms
memory: 3696kb

input:

100
119 974
198 554
187 853
115 662
258 632
410 775
468 582
367 717
121 938
280 618
262 869
374 950
344 877
203 729
83 650
165 560
428 969
500 702
233 897
289 529
305 531
411 567
203 813
449 855
343 882
517 462
781 461
871 374
794 164
965 48
806 51
974 150
979 51
940 420
852 202
940 345
501 196
663 ...

output:

152497
119630
183788
99123
158655
283245
227923
245555
148113
173995
230475
313611
288295
159230
82389
109316
342177
283203
215420
144491
151679
202577
183350
324299
288447
177535
303083
296911
158184
90776
76906
186140
95486
335285
194654
303099
98559
140954
336017
164116
281639
280529
143210
14660...

result:

ok 100 lines

Test #4:

score: 0
Accepted
time: 1ms
memory: 3616kb

input:

100
16541 99813
41457 85189
39718 86573
32613 61161
47902 61001
15965 90060
16857 83242
13774 86675
20467 97347
35730 58254
7362 73104
1754 86078
40673 66968
32796 76717
7479 77710
25204 67239
5688 56809
12907 84557
21067 52094
31655 93093
9980 54413
48685 77594
37506 91316
49306 91178
26392 52132
7...

output:

490293308
824740523
812034789
428844641
579598608
423739185
420805458
392852859
553232642
479597712
213975810
110959906
591775185
583369489
233021514
435990512
144747209
369141569
320188501
667531100
200788994
806331887
814551715
971663383
363165115
455372420
645796248
262520252
470116454
718453609
...

result:

ok 100 lines

Test #5:

score: 0
Accepted
time: 1ms
memory: 3688kb

input:

100
25247 97555
42744 88848
13961 97989
46544 89408
49839 92041
9246 79475
25644 60821
46119 96318
2874 85269
33180 79518
41096 84045
9548 66451
3950 59706
3415 59118
31524 74990
44205 51466
26390 58740
15770 67554
12539 64816
48514 96415
528 58612
17325 69609
20886 66120
40216 88107
32831 95342
764...

output:

623764022
878127445
433154801
926836969
993681191
282196199
394908475
973786461
150828279
621146697
803866681
238418393
116968344
110578764
562397196
521153136
393861723
311705595
262906588
991126181
36041122
358292522
380483382
826449985
688871901
658924823
337969287
578194896
475089870
441600506
2...

result:

ok 100 lines

Test #6:

score: 0
Accepted
time: 1ms
memory: 3692kb

input:

100
43411 53734
5228 95025
25736 51275
9774 99644
7768 99745
15819 80524
40584 58155
29479 73913
29761 75983
1638 65002
45205 53887
27671 86198
43431 93311
21204 97515
34383 51824
12259 84834
2994 57312
28413 74523
42963 79761
38476 75929
12092 54839
899 86936
11963 59348
16117 65580
806 58983
98410...

output:

529522864
245784356
353212539
374844681
308601100
367741749
520573840
537392924
560518196
79273739
540003440
609027334
927761081
573374762
432049840
353030519
98115146
534701948
781980125
695885395
224426434
75272229
241776966
291698009
47230396
899982507
729795063
439285684
536819712
403669045
5264...

result:

ok 100 lines

Test #7:

score: 0
Accepted
time: 217ms
memory: 3640kb

input:

100000
40263 8268474
2297709 6546150
3020220 7042526
1237691 9254214
4639992 5734413
1927687 6847701
4984397 8122507
703935 8973914
3941580 6788583
3075826 9716921
4253336 9605863
3843521 5492180
2819072 9122248
669334 7553383
1964889 8867928
711227 7999667
1744283 7999661
791361 6877821
2443863 622...

output:

127313370
244053560
531519863
102076558
8850304
312541864
722064591
308518878
256523158
109077813
745224099
740337654
933207483
118584105
846675845
352433573
726817180
18638706
147332069
533188126
830908088
403602782
380752303
536356274
883702480
455284218
770399638
801129646
944102783
567490832
341...

result:

ok 100000 lines

Test #8:

score: 0
Accepted
time: 221ms
memory: 3692kb

input:

100000
2409146 9897236
4611824 8054137
39443 6670658
3158386 9110580
130330 8350469
3351480 6295573
1471046 8197370
1656349 8226679
59773 8762702
853568 7860314
1505807 6256685
3365281 7747336
4098127 8979986
595720 9089071
857944 8209713
1529511 7798844
3937475 7531842
1334299 7611940
2017468 78170...

output:

788335190
947803032
921426071
403909926
491956715
999049740
829133482
177440041
105697591
420181041
399865006
75075064
116528936
830904185
358852578
361921648
341559753
625397731
640620233
575870393
803959104
929664650
273829922
769235174
513570073
881330279
149159313
757157028
916024674
423219023
7...

result:

ok 100000 lines

Test #9:

score: 0
Accepted
time: 219ms
memory: 3668kb

input:

100000
1392070 5270024
4792567 8627725
4616106 8369402
1550149 7589003
3232702 9352398
4386155 7609512
2136608 7141335
2733909 9243224
3392000 9545788
3262228 6500964
2814802 7037319
2652365 9740684
21366 5879879
4928192 9245721
4392654 5530688
657212 9273555
2082943 9972133
3289905 9929934
2267358 ...

output:

896555950
96079953
598560864
316385938
401313774
499058038
600781994
178724206
492880759
862067133
247114966
334088907
63630823
557345470
261943099
27902876
638656600
179180062
603188004
735618520
894979327
950754210
263037990
488552915
704416087
152154946
164934213
975745074
698285097
239564011
887...

result:

ok 100000 lines

Test #10:

score: 0
Accepted
time: 288ms
memory: 3616kb

input:

100000
271462186 764322428
12393009 849495225
448477941 902999806
414276559 874327010
225145271 994078795
394706463 740366701
116125833 750813800
265138927 876905602
184207012 786399990
331007680 838398590
428684379 715935367
485118085 759903934
487200706 877066967
171223898 628448397
19847700 79601...

output:

868227428
590126977
653325747
406160106
108942610
14391049
47570351
724418818
876986817
283310734
242396364
674373878
14951052
703842557
556874727
615641513
165158329
301849139
502941058
256346772
678377078
763451214
582584761
468342798
76305899
769618281
334006154
204163098
655142501
60184256
62245...

result:

ok 100000 lines

Test #11:

score: 0
Accepted
time: 282ms
memory: 3692kb

input:

100000
237231818 518310440
196076956 869820364
328639725 508985654
277450614 700041543
149096361 637225817
381753301 933449671
311481448 878815656
195447030 603687083
353896521 920341534
279779364 783407520
404893075 722968076
321747334 642760741
302843374 994110594
195092028 816520775
228391619 702...

output:

354241277
121920431
149615804
830286959
736357415
958681911
779367762
735697225
895711039
644189137
916822330
819723869
903860051
27791389
955274695
213769121
320334343
948518946
229415558
383671728
987211250
593878226
834009597
419644511
851342045
526062
13667226
330583308
513778704
254129687
24931...

result:

ok 100000 lines

Test #12:

score: 0
Accepted
time: 286ms
memory: 3696kb

input:

100000
161950031 527901947
319830601 871592908
280980804 906150875
186792468 662848436
200561210 767556673
473624146 753809022
78192292 929494612
398179767 866395573
86251495 962555100
244332826 559466523
122832915 976647126
312127025 831142787
189915932 564913577
122803401 510889178
8492434 7577029...

output:

756531171
573488402
299710486
356045513
179287827
745853194
453009517
443789671
545220365
262994116
959203639
271588046
335660160
613202802
680724782
160072996
747942281
932593297
332102685
452055379
611116358
130823432
220626664
277056250
120069494
928431195
45046204
278675961
863977569
52011730
39...

result:

ok 100000 lines

Test #13:

score: 0
Accepted
time: 175ms
memory: 3620kb

input:

100000
421717671 1
1 155276943
0 983813438
1 784308025
89842566 1
838747463 1
1 480183220
0 890807913
0 276749484
808402301 1
778711957 1
942059924 0
1 692734240
829677807 0
1 166612930
617604573 1
833588183 1
0 212574132
0 248644213
208524847 0
1 235658960
0 862380956
118606773 1
1 314957256
0 7113...

output:

539412247
118978424
440661151
683248205
437297366
133022894
82663622
650495422
488864105
767490618
431425145
188055738
562427923
816592256
595089892
181592914
900855301
683640234
693602495
570260254
495023131
797686719
602247729
895334244
265514567
276631962
396374009
315746301
114045190
411439569
5...

result:

ok 100000 lines

Test #14:

score: 0
Accepted
time: 183ms
memory: 3692kb

input:

100000
271876108 12
653907356 13
5 574882506
158947119 3
2 523259122
13 801897917
901003268 4
1 984628361
575734436 3
8 154859178
8 992332679
3 907633357
511775015 0
488531094 13
180733035 0
8 278059824
3 757052944
8 313080644
15 208191418
48362470 11
11073980 9
12 953060836
825457418 15
25031071 7
...

output:

900797249
399459266
518199953
409688726
275287140
43078572
379979286
697663262
446155199
762033681
197923847
849332205
304604455
448837867
792089525
166598018
685154405
102062710
152179393
356419515
27118299
710895192
930527164
998750499
933953886
364182522
799254
890780077
854065454
549058846
89545...

result:

ok 100000 lines

Test #15:

score: 0
Accepted
time: 199ms
memory: 3672kb

input:

100000
968693249 75
11 765783212
689544514 66
234 976417316
994257278 135
167 271321332
46 823882183
177 762112056
452630617 76
427142493 223
898583928 152
535184569 73
807120368 194
910525760 204
945198380 251
896490857 40
125 214301330
233 179397490
523909527 108
765396802 192
316869842 35
7197006...

output:

760931918
548895148
12296334
862794959
810986299
287164674
643743330
691610954
301200239
460787565
841810836
574655663
725088324
988710966
254092228
106254434
802293896
796046357
286268
111765194
437717869
425997846
410111635
571903168
981478155
821822824
537078743
698805105
631747406
38315169
94767...

result:

ok 100000 lines

Extra Test:

score: 0
Extra Test Passed