QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#312613#2856. 数字表格blln100 ✓853ms31576kbC++201.5kb2024-01-24 06:50:472024-01-24 06:50:47

Judging History

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

  • [2024-01-24 06:50:47]
  • 评测
  • 测评结果:100
  • 用时:853ms
  • 内存:31576kb
  • [2024-01-24 06:50:47]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=1e6+5,Mod=1e9+7,mod=Mod-1;
int T,n,m,Ans,P=0,f[N+5],F[N+5],JC[N+5],NY[N+5],Pr[N+5],Pz[N+5],Mr[N+5],Mz[N+5];
inline int Ksm(int t1,int t2){int t3=1;for(;t2;t1=1ll*t1*t1%Mod,t2>>=1)if(t2&1)t3=1ll*t1*t3%Mod;return t3;}
inline int Add(int t1,int t2){t1+=t2;if(t1>Mod)t1-=Mod;return t1;}
inline void YCL(){
    Mr[1]=1;f[0]=0;f[1]=1;JC[0]=1;
    for(int i=2;i<=N;i++){
        if(!Pz[i]){P++;Pr[P]=i;Mr[i]=-1;}f[i]=Add(f[i-1],f[i-2]);
        for(int j=1;j<=P&&i*Pr[j]<=N;j++){
            Pz[i*Pr[j]]=1;
            if(i%Pr[j]==0){Mr[i*Pr[j]]=0;break;}
            Mr[i*Pr[j]]=Mr[i]*Mr[Pr[j]];
        }
    }
    for(int i=1;i<=N;i++)Mz[i]=Mr[i]+Mz[i-1],Mr[i]=Mr[i]<0?Mr[i]+mod:Mr[i],F[i]=1;
    for(int i=1;i<=N;i++)for(int j=1;j*i<=N;j++)F[i*j]=1ll*F[i*j]*Ksm(f[i],Mr[j])%Mod;
    // for(int i=1;i<=10;i++)printf("%lld ",F[i]);
    for(int i=1;i<=N;i++)JC[i]=1ll*JC[i-1]*F[i]%Mod;NY[N]=Ksm(JC[N],Mod-2);
    for(int i=N;i>=1;i--)NY[i-1]=1ll*NY[i]*F[i]%Mod;
}
inline int QZ(int kn,int km){
    int s=0;
    for(int i,j=1,k=min(kn,km);j<=k;j=i+1)i=min(kn/(kn/j),km/(km/j)),s=(s+(1ll*Mz[i]-Mz[j-1]+mod)%mod*(kn/i)%mod*(km/i)%mod)%mod;
    return s;
}
int main(){
    YCL();
    scanf("%d",&T);
    while(T--){
        scanf("%d %d",&n,&m);Ans=1;
        for(int i,j=1,k=min(n,m);j<=k;j=i+1){
            i=min(n/(n/j),m/(m/j));
            Ans=1ll*Ans*Ksm(1ll*JC[i]*NY[j-1]%Mod,1ll*(n/i)*(m/i)%mod)%Mod;
        }
        printf("%d\n",Ans);
    }
}

详细

Test #1:

score: 10
Accepted
time: 669ms
memory: 31500kb

input:

1000
82 5
85 13
18 82
39 47
85 97
28 33
72 40
38 43
76 44
9 45
57 96
3 54
60 20
43 30
45 46
11 53
14 84
50 90
10 39
39 20
70 50
95 13
36 54
47 82
47 52
68 44
36 53
13 94
100 69
56 80
16 28
93 10
52 39
66 75
68 17
37 74
66 64
5 69
34 84
74 21
44 67
36 3
26 55
20 54
43 50
67 14
49 54
13 11
4 59
83 72
...

output:

697857603
513287135
493843565
685803126
740209982
40610353
396156831
744451085
76570868
570036963
171027959
262144
893084879
939049770
926146193
722919138
964641357
942426458
622528402
451760491
14237564
225318722
518777888
449825043
341812093
432079000
772254207
169012750
411792446
748968062
756385...

result:

ok 1000 lines

Test #2:

score: 10
Accepted
time: 670ms
memory: 31436kb

input:

1000
456 760
791 350
655 528
2 279
69 639
512 306
308 162
717 572
992 483
222 419
425 368
391 134
541 346
150 960
852 350
270 993
338 455
197 621
281 194
446 443
157 488
776 127
54 512
902 953
321 874
397 451
655 813
305 303
372 210
655 671
689 895
332 867
219 734
189 279
490 563
45 794
43 1
907 328...

output:

384572586
128416505
177153016
1
792110166
378466851
634682075
140555279
785606784
224545347
480461357
787221913
152690988
276697635
873944871
15937156
787784125
74845458
378183569
770058883
553415281
664773218
54099655
4520332
136745043
642040144
647801092
694272606
411423640
772548747
991414475
262...

result:

ok 1000 lines

Test #3:

score: 10
Accepted
time: 654ms
memory: 31392kb

input:

1000
834 24
939 905
741 833
728 412
665 30
90 620
517 891
130 313
639 707
544 959
223 611
85 709
250 300
322 983
393 173
407 404
831 110
165 881
991 422
885 165
819 590
815 411
926 844
220 395
363 553
555 993
435 636
704 644
900 365
424 960
149 578
894 636
986 805
554 661
798 699
77 762
172 751
166 ...

output:

644802145
232279121
379400155
444492502
954058278
813885568
18387337
502115986
340496387
84878668
494148625
561893309
729783825
495024707
306032686
744614950
310694222
151470960
67195602
891797129
572646117
912571586
762567644
631897452
923582319
898125642
924489975
992290630
669842153
864854675
343...

result:

ok 1000 lines

Test #4:

score: 10
Accepted
time: 672ms
memory: 31432kb

input:

3
454940 562672
112643 767306
907862 417181

output:

695663156
628427697
686722724

result:

ok 3 lines

Test #5:

score: 10
Accepted
time: 664ms
memory: 31432kb

input:

3
745197 513056
269960 979569
208740 376976

output:

634928413
640591579
861814959

result:

ok 3 lines

Test #6:

score: 10
Accepted
time: 661ms
memory: 31432kb

input:

3
121356 462155
298930 200313
460606 503275

output:

748574275
576920
859930990

result:

ok 3 lines

Test #7:

score: 10
Accepted
time: 852ms
memory: 31528kb

input:

1000
283558 168544
143615 807608
461779 307243
759795 341819
791247 562279
899971 582242
112436 804931
512924 539518
506466 351699
256430 581061
65275 126030
432494 604369
369382 716240
614292 212703
246925 304537
770781 488081
760542 135820
242826 868717
832206 664944
689055 660507
477009 178162
25...

output:

283014868
990243232
388248159
616196065
219886182
309382041
448679213
534956539
918843207
55781398
824669761
474166751
307997809
151932376
500358371
591586078
682389632
341823993
554507625
688852617
634347229
172864935
122553460
202758604
858950400
301189134
1594673
617393878
170625580
610595922
172...

result:

ok 1000 lines

Test #8:

score: 10
Accepted
time: 853ms
memory: 31576kb

input:

1000
440274 901599
691601 797856
838055 495802
684464 663111
25477 958082
634124 986486
784532 84086
595489 737743
803588 746107
507375 445527
429256 581591
105532 192505
129686 524151
510160 547137
9897 903082
906231 195234
529919 163684
992899 24432
718107 697468
300039 232039
619908 616814
437725...

output:

365320913
681614706
847286353
671477779
264121697
585088898
368905317
11027303
889121172
109652792
80510572
642059979
480108117
599586524
900360019
164051816
395310915
906701911
787811872
790784785
818963886
763793845
335411670
167129596
14877864
617021327
830035095
90699668
633416819
100892835
2193...

result:

ok 1000 lines

Test #9:

score: 10
Accepted
time: 848ms
memory: 31520kb

input:

1000
82099 145723
916973 256099
847467 5679
827410 634711
814947 648717
452883 705336
279959 643364
526334 114296
171651 647528
93859 297708
405036 664496
286039 691597
194839 977656
79922 965177
949648 362655
190289 994355
414692 338602
373526 895198
362151 16511
279011 797510
181551 695915
901667 ...

output:

892557352
602766132
609986864
451863890
987591917
727546364
493768397
360043516
725932491
358432557
924555808
537966114
376147353
644329506
82216168
421049387
709247573
201697130
818623765
165832955
251779127
289533274
127590777
387082723
933248973
862380388
298729759
964486678
532229940
144255370
9...

result:

ok 1000 lines

Test #10:

score: 10
Accepted
time: 834ms
memory: 31432kb

input:

1000
289425 176253
54044 388424
551782 18069
271647 334132
2932 750739
280736 422385
118021 716182
675003 529602
507815 849891
921488 524106
871151 656480
728325 392405
388722 388186
661186 781712
111306 853376
921908 442700
128791 264037
219787 338943
816123 586242
51579 729859
671516 827378
823742...

output:

941313418
330479975
400191059
317961212
608283349
768465305
270252947
548702642
348199404
783788857
325184947
319667541
309227985
601658259
556002932
783792811
164680409
830772331
781714629
345353453
68627791
609976729
790036886
838208236
772779707
712165773
786518563
5069623
916902879
262508186
809...

result:

ok 1000 lines