QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#478493 | #8486. Casino | rania__# | WA | 9ms | 4648kb | C++23 | 1.3kb | 2024-07-15 02:14:04 | 2024-07-15 02:14:04 |
Judging History
answer
#pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef int in;
#define int long long
#define double long double
#define f first
#define s second
#define pb push_back
#define pp push
#define ceill(x,y) ((x/y)+(x%y!=0)*(x/abs(x)*y/abs(y)<0?0:1))
#define floorr(x,y) ((x/y)+(x%y!=0)*(x/abs(x)*y/abs(y)<0?-1:0))
#define YN(x) cout<<(x?"YES\n":"NO\n");
#define Yn(x) cout<<(x?"Yes\n":"No\n");
#define yn(x) cout<<(x?"yes\n":"no\n");
const int MAAX=1e18;
const int MOD=1e9+7;
const int MAX=1e9;
int power(int x,int y){
if(y==0)
return 1;
int z=power(x,y/2);
z*=z;
z%=MOD;
if(y%2)
z*=x;
z%=MOD;
return z;
}
int mi(int x,int y){
return (x*power(y,MOD-2))%MOD;
}
int fact(int x){
if(x<2)
return 1;
return x*fact(x-1)%MOD;
}
int n,arr[100010];
in main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int tc=1;
// cin>>tc;
while(tc--){
cin>>n;
int a=0,b=0,c=0;
//(a+b-1)!/(a!*(b-1)!)
for(int i=0;i<n;i++){
int x;
cin>>x;
if(x%3==0)
a++;
else if(x%3==1)
b++;
else
c++;
}
if((b+c*2)%3==0){
cout<<"0\n";
continue;
}
cout<<mi(fact(a)*fact(b)%MOD*fact(c)%MOD*fact(n-1)%MOD,fact(a)*fact(b+c-1)%MOD)<<"\n";
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3576kb
input:
3 100 21 892
output:
4
result:
ok 1 number(s): "4"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3688kb
input:
4 11 19 30 32
output:
6
result:
ok 1 number(s): "6"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3704kb
input:
3 4 298 28
output:
0
result:
ok 1 number(s): "0"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3688kb
input:
5 24 27 38 46 94
output:
24
result:
ok 1 number(s): "24"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3636kb
input:
5 72 84 11 51 21
output:
24
result:
ok 1 number(s): "24"
Test #6:
score: 0
Accepted
time: 0ms
memory: 3560kb
input:
5 84 51 12 6 69
output:
0
result:
ok 1 number(s): "0"
Test #7:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
5 30 66 27 36 60
output:
0
result:
ok 1 number(s): "0"
Test #8:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
10 98 39 37 19 45 73 83 42 73 3
output:
145152
result:
ok 1 number(s): "145152"
Test #9:
score: 0
Accepted
time: 0ms
memory: 3712kb
input:
10 89 34 37 93 47 12 56 26 3 51
output:
145152
result:
ok 1 number(s): "145152"
Test #10:
score: 0
Accepted
time: 0ms
memory: 3708kb
input:
10 73900926 31166686 581758479 266084782 136544545 864189216 334829736 346199618 111407115 84881126
output:
181440
result:
ok 1 number(s): "181440"
Test #11:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
10 374350674 408667992 305815278 141080955 705187668 53250180 908378583 123881433 725492762 607387956
output:
362880
result:
ok 1 number(s): "362880"
Test #12:
score: 0
Accepted
time: 0ms
memory: 3652kb
input:
1000 24551 8084 73369 96016 90782 37319 35797 64970 52459 16561 61141 54762 81069 80237 48601 10843 1202 65279 4195 55258 89827 47014 78376 60803 51120 5914 48347 55895 88511 79208 49307 94324 26969 13367 92230 59021 13418 75515 19883 66005 49541 35616 49829 78359 709 63677 77152 45916 68528 54254 7...
output:
856284522
result:
ok 1 number(s): "856284522"
Test #13:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
1000 48691 46538 83136 46036 71758 14694 13100 5781 97689 76006 44177 74676 93176 31340 41494 86339 55249 39544 46880 94896 88937 9345 75252 73414 98268 65240 49568 66888 50763 55836 3756 21457 52521 5787 84264 34850 95493 63753 55238 32771 81619 90007 17373 35056 51906 17186 62916 12882 7006 6353 9...
output:
104068234
result:
ok 1 number(s): "104068234"
Test #14:
score: 0
Accepted
time: 1ms
memory: 3656kb
input:
10000 67019 843459 643000 222974 581964 465799 161554 692789 783254 762805 936066 784466 490517 450618 416891 994505 531888 215338 892395 470532 660640 20964 726823 80040 260577 27895 940779 639052 398685 41661 629665 631243 76557 530475 411831 988371 47682 759130 885212 475131 641539 946530 793394 ...
output:
75531231
result:
ok 1 number(s): "75531231"
Test #15:
score: 0
Accepted
time: 1ms
memory: 3720kb
input:
10000 269718 881031 970470 349479 584418 519285 775143 745290 288480 908997 396750 777762 35241 790692 662334 614694 946332 384483 875742 24804 808923 597105 423093 980430 346848 66231 188568 8007 562785 631782 837633 992181 851259 764025 769746 300339 381234 110526 689535 453990 569928 487899 56223...
output:
291223019
result:
ok 1 number(s): "291223019"
Test #16:
score: 0
Accepted
time: 7ms
memory: 4516kb
input:
100000 719070 126576 692367 905361 377523 802356 775317 712461 34146 234291 655635 754425 934917 44338 381879 801225 423978 478229 359352 808089 591960 826566 410529 367422 808443 536325 231188 299760 990255 692928 474137 238317 147768 978636 927645 811116 35364 546072 129681 762951 284313 498120 66...
output:
534487341
result:
ok 1 number(s): "534487341"
Test #17:
score: 0
Accepted
time: 7ms
memory: 4576kb
input:
100000 275109 287835 38691 96075 271662 343521 979791 638907 115789 212055 478158 488622 45723 296841 223542 26004 548883 968859 615453 891404 203119 515400 469884 378579 935346 529125 185916 975651 467769 552543 905457 394152 481323 219522 929175 80859 32079 138888 407619 626844 364928 701685 41411...
output:
937699324
result:
ok 1 number(s): "937699324"
Test #18:
score: 0
Accepted
time: 8ms
memory: 4644kb
input:
100000 559619 635425 749380 537563 573710 778780 191335 164077 707134 990790 10442 499360 371410 376109 504714 383203 776297 893783 46850 912476 850635 121980 783086 611560 311557 302279 887742 100400 97167 21391 264448 801140 927460 821849 651923 496287 394110 387132 328332 244636 709580 863247 215...
output:
801257591
result:
ok 1 number(s): "801257591"
Test #19:
score: 0
Accepted
time: 7ms
memory: 4644kb
input:
100000 361476 26187 465800 826840 790696 679906 414403 911722 860847 805406 220958 513623 861776 4632 46985 466233 811305 326917 405995 672933 74940 208584 797269 70259 626188 828936 830119 902947 268882 103199 538657 950506 762990 944363 702463 240738 500695 333346 670627 351500 187418 694459 77921...
output:
625811000
result:
ok 1 number(s): "625811000"
Test #20:
score: 0
Accepted
time: 8ms
memory: 4516kb
input:
100000 678185 5790068 1551158 6260459 759956 1390682 2517307 6825143 2108618 854449 3573711 8747350 7893220 3637636 4102271 8431480 7291654 207859 9659011 1385040 4824439 3176911 9886195 3543109 7770563 9652727 8410505 6300844 470889 1338149 8849716 8470849 1853035 4348477 1472290 521270 1183064 685...
output:
650116699
result:
ok 1 number(s): "650116699"
Test #21:
score: 0
Accepted
time: 8ms
memory: 4564kb
input:
100000 8325313 989195 42377 7276214 2242630 7021318 3731183 7379099 7579906 4480864 9272614 2593960 5258414 7096181 9675146 6431900 7849097 6346753 4234618 8230412 1519181 2051701 5062271 9650992 9816784 4598753 4463902 9659339 2778493 3565912 8230520 4847035 8709077 2411107 2782614 4801391 7620817 ...
output:
178464958
result:
ok 1 number(s): "178464958"
Test #22:
score: 0
Accepted
time: 2ms
memory: 4552kb
input:
100000 22417628 15768346 37166352 33456312 91804378 20831948 75619049 40003312 31870801 86664525 81787955 77200916 15747834 27642743 39012656 737209 9846364 84062514 16536001 94518081 55350518 71821288 58568334 67550999 14658512 93917770 18688556 34400543 5352271 69777745 52637462 91873227 11592829 ...
output:
912437569
result:
ok 1 number(s): "912437569"
Test #23:
score: 0
Accepted
time: 5ms
memory: 4580kb
input:
100000 67027283 23061766 61177301 68029181 34232382 33984922 96463197 17148439 38828944 68470804 27029774 63697244 86431105 21312475 95924341 2961454 7567137 34273012 16541132 39505461 79625272 80889073 52744730 76784288 27888800 47702840 71062423 58527925 56390174 69845428 12580819 14451227 1746457...
output:
32413684
result:
ok 1 number(s): "32413684"
Test #24:
score: 0
Accepted
time: 2ms
memory: 4516kb
input:
100000 52931777 69116350 83743259 29269961 86791741 22752206 46737038 17243233 9097465 56306432 27286790 10180555 60096425 83546462 48124691 77435734 44057853 64673872 79184401 24664828 90557187 44308741 2816531 10847780 96197960 97728596 59476127 76056833 63814844 76761976 74008279 84024158 5233065...
output:
256478495
result:
ok 1 number(s): "256478495"
Test #25:
score: 0
Accepted
time: 9ms
memory: 4500kb
input:
100000 88240471 11472786 60479236 13861448 21574091 23468513 19343791 65237245 70845584 56815274 78043052 63792976 6941138 94557502 22488284 97344751 11563846 6432743 2076557 98435440 50806517 3670451 9162709 38927770 82513429 38157265 45136702 71602402 50101907 32426759 37911088 48235051 49964812 9...
output:
202969365
result:
ok 1 number(s): "202969365"
Test #26:
score: 0
Accepted
time: 9ms
memory: 4452kb
input:
100000 881643201 902233733 463382621 261166661 593626103 941406753 506118497 395515140 252678929 999787338 251946357 873741996 382418162 830622626 686827460 889631879 683596192 843051741 789187605 173486923 905110541 794445972 320399815 476292672 189928572 738483774 33584073 23279052 734495192 32683...
output:
724538641
result:
ok 1 number(s): "724538641"
Test #27:
score: 0
Accepted
time: 6ms
memory: 4648kb
input:
100000 518981955 73027794 259915248 440745025 880632132 194323000 768277631 793498620 391363501 939692455 408592626 378675434 205962444 369181326 988329351 76266796 865223992 48510658 912268078 805634706 484737193 615463749 237985366 196121099 80004509 681709317 813361870 443630218 169495616 3676011...
output:
941015803
result:
ok 1 number(s): "941015803"
Test #28:
score: 0
Accepted
time: 8ms
memory: 4644kb
input:
100000 270193083 747743325 335962227 281935854 313074525 10268019 548508018 316660347 593129094 78169506 566907411 273425040 881878911 290449260 765847383 228445317 199024671 503416236 261934923 797465313 995488197 398109930 843465192 369631506 645326448 925676949 611768538 235173999 631332702 23701...
output:
479780718
result:
ok 1 number(s): "479780718"
Test #29:
score: 0
Accepted
time: 8ms
memory: 4644kb
input:
100000 651775764 824294589 419827728 125070357 765871668 904566591 798018327 925715067 972425775 596189940 732798915 609888205 302265963 918057915 46327995 284782233 172514260 266800142 4780629 758832477 747280896 149135658 201810219 217833459 580692747 782287611 188031345 287089722 126132081 727498...
output:
286147707
result:
ok 1 number(s): "286147707"
Test #30:
score: -100
Wrong Answer
time: 9ms
memory: 4576kb
input:
100000 999999999 999999999 1000000000 999999999 1000000000 1000000000 999999999 999999999 999999999 999999999 999999998 1000000000 1000000000 999999998 999999999 999999999 999999998 1000000000 999999998 999999998 1000000000 1000000000 999999998 1000000000 1000000000 999999999 999999999 999999999 100...
output:
925710716
result:
wrong answer 1st numbers differ - expected: '0', found: '925710716'