QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#506563 | #6168. 异构序列码性态问题 | DaiRuiChen007 | 0 | 493ms | 23616kb | C++17 | 744b | 2024-08-05 19:27:58 | 2024-08-05 19:27:59 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,MOD;
ll ksm(ll a,ll b=MOD-2,ll p=MOD) {
ll ret=1;
for(;b;a=a*a%p,b>>=1) if(b&1) ret=ret*a%p;
return ret;
}
const int MAXN=1e7+5;
ll fac[MAXN],ifac[MAXN];
ll C(int x,int y) { return fac[x]*ifac[y]%MOD*ifac[x-y]%MOD; }
void solve() {
if(n<=2) return puts("0"),void();
for(int i=fac[0]=1;i<=2*n;++i) fac[i]=fac[i-1]*i%MOD;
ifac[2*n]=ksm(fac[2*n]);
for(int i=2*n;i;--i) ifac[i-1]=ifac[i]*i%MOD;
ll ans=0,pw=2;
for(int i=0;i<=n;++i) {
ans=(ans+((n-i)%2?-1:1)*pw*C(n+i,n-i)%MOD*(i?C(2*i,i)-C(2*i,i-1):1))%MOD;
pw=pw*2%MOD;
}
printf("%lld\n",(fac[n+1]+MOD-ans)%MOD);
}
signed main() {
while(~scanf("%d%d",&n,&MOD)) solve();
return 0;
}
詳細信息
Pretests
Final Tests
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 5900kb
input:
1329 281979259 3946 347158051 3102 613279651 4193 175275013 494 674092373 549 240448331 3924 588857561 1719 782159639 1781 270936499 672 589936439
output:
110289002 18928865 553791397 130619861 310158386 196629475 279162593 174129151 125909962 286353402
result:
wrong answer 1st numbers differ - expected: '9022243', found: '110289002'
Test #2:
score: 0
Wrong Answer
time: 0ms
memory: 5924kb
input:
2013 239960621 2839 377547413 4864 996482101 3196 204395311 1568 653611141 753 104807119 3006 755688737 3047 697114861 2943 384316589 2413 512454407
output:
54816773 217342231 48460026 7742203 324187253 74530514 119681871 485017666 189731934 33697707
result:
wrong answer 1st numbers differ - expected: '127514501', found: '54816773'
Test #3:
score: 0
Wrong Answer
time: 2ms
memory: 5912kb
input:
4542 497374921 4375 144420547 3310 175379389 1159 776452463 642 401409289 1214 754051891 1956 962928761 3925 282058753 2664 215149997 2050 912416861
output:
384151779 133212008 136179097 189911947 324684138 720447011 930685348 98426525 23262228 103429556
result:
wrong answer 1st numbers differ - expected: '234466993', found: '384151779'
Test #4:
score: 0
Wrong Answer
time: 2ms
memory: 6072kb
input:
4808 349909687 4602 991037059 108 14516431 3384 974151743 1250 726146471 4891 585626857 3617 211451333 358 425997931 2891 654329051 4814 64701121
output:
94891692 758700049 2867081 367259907 693698159 145660062 57345049 84239502 239336916 8512668
result:
wrong answer 1st numbers differ - expected: '334429486', found: '94891692'
Test #5:
score: 0
Wrong Answer
time: 2ms
memory: 5904kb
input:
1107 524640323 1847 933584471 3406 582135349 4007 51397727 80 570372863 4186 193850947 1773 505708747 59 753490921 4244 207441401 723 3432577
output:
80268213 5857982 235363733 39227615 58953559 71354764 301202554 464131177 85180489 1792869
result:
wrong answer 1st numbers differ - expected: '28404629', found: '80268213'
Test #6:
score: 0
Wrong Answer
time: 158ms
memory: 22960kb
input:
350598 149719567 5656 639718861 182032 562484129 321578 733607449 396666 977259137 289217 738297893 94787 357806747 130763 912856261 129615 332700631 439091 653900939 228198 805737671 421386 35411809
output:
121588027 350530930 202517025 244130136 277595818 71712825 209864868 590888860 292775146 356368825 51564939 16399836
result:
wrong answer 1st numbers differ - expected: '17579808', found: '121588027'
Test #7:
score: 0
Wrong Answer
time: 215ms
memory: 22884kb
input:
71980 730430429 365591 519176123 421874 939796883 442008 891121537 196686 57507407 481211 220812971 351047 410650543 262764 313392899 434798 192402149 113530 421210637 359403 379486343 396967 813975307 193616 995122811
output:
537187356 15763063 183332245 853713435 49164045 212766302 214714610 238737038 123547119 380569685 77111748 732739148 301568595
result:
wrong answer 1st numbers differ - expected: '327860411', found: '537187356'
Test #8:
score: 0
Wrong Answer
time: 267ms
memory: 23616kb
input:
412065 473565137 427460 278321429 481215 341626709 248825 235725317 391371 550178417 166694 541821383 3035 184388593 166130 370451243 342592 79808159 98863 640391243 416610 96090131 479715 456938333 407065 630349243 289928 807773149 486842 415008521 300760 618573047
output:
186552115 41896566 88687349 137577461 519532113 369958475 113167751 229169790 47986401 245529937 42145576 99165648 589520019 282234612 347758622 120310013
result:
wrong answer 1st numbers differ - expected: '227856800', found: '186552115'
Test #9:
score: 0
Wrong Answer
time: 484ms
memory: 21628kb
input:
401210 376894061 112020 976190981 76624 418721741 308217 29130763 275157 939661747 35829 250363831 178538 424627327 456973 351281803 88075 992733541 281595 311233067 104622 151994753 271593 41245261 319132 947462657 186811 961154149 227249 86441119 165977 701025443 471204 999330173 296567 685415303 ...
output:
8526324 159100792 259884407 17901746 660605497 137277421 7984570 38832510 72471663 65007871 103634472 38263934 375334612 621506208 55160055 343611921 502752037 570407964 57454278 809668325 383417537 479862854 270301165 32402854 19530106 80908973 206394477 158501405 30723045 157904523 480411402 25105...
result:
wrong answer 1st numbers differ - expected: '137731023', found: '8526324'
Test #10:
score: 0
Wrong Answer
time: 493ms
memory: 19948kb
input:
372965 157601299 239698 272457617 40399 596646311 315339 562161443 166279 292784099 224605 629707601 14534 7015139 478528 718703087 129027 957763397 44039 880925107 420271 933815867 323410 164444393 160117 572839451 344095 28487981 473223 648555881 469070 150428897 447149 993828707 214989 982422577 ...
output:
96123620 198891021 500341182 529968065 129323167 18974267 3976425 267731613 91051801 527399583 139530004 29597346 8236123 24745356 427411187 49496212 371543664 227297877 6220809 12488171 343807751 179801188 382484010 99971993 59191449 238258563 102265382 39142332 2114468 168858795 33315068 10401408 ...
result:
wrong answer 1st numbers differ - expected: '109121987', found: '96123620'