UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#173824#65. triangleddh1231006412ms16772kbC++11922b2023-07-20 12:36:452023-07-20 12:36:46

answer

#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll read()
{
  ll x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9')
  {
    if (ch == '-')
      f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
  {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = getchar();
  }
  return x * f;
}
ll T,a,b,n,m,mod=1000000009,fac[1000005],inv[1000005];
ll qp(ll a,ll b){
	ll t=a,res=1;
	while(b){
		if(b%2)
			res=res*t%mod;
		t=t*t%mod,b>>=1;
	}
	return res;
}
ll mul(ll a,ll b,ll c){
	return a*b%mod*c%mod;
}
ll C(ll n,ll m){
	return mul(fac[n],inv[n-m],inv[m]); 
}
int main(){
	T=read();
	fac[0]=inv[0]=1;
	for(int i=1;i<=1e6;i++)
		inv[i]=qp(fac[i]=fac[i-1]*i%mod,mod-2);
	while(T--){
		a=read(),b=read(),n=read(),m=read();
		if(m<1||m>n)
			puts("0");
		else
			printf("%d\n",mul(qp(a,n-m),qp(b,m-1),C(n-1,m-1)));
	}
	return 0;
}
 

详细

小提示:点击横条可展开更详细的信息

Test #1:

score: 10
Accepted
time: 577ms
memory: 16768kb

input:

100
992571778 662628270 60 3
740164762 639918734 93 35
413999655 864387342 67 52
490343414 679767370...

output:

872808721
924340102
300262844
291973237
877463069
972169065
772190116
395156905
994943045
778820226
...

result:

ok 100 lines

Test #2:

score: 10
Accepted
time: 584ms
memory: 16768kb

input:

100
62793610 802527059 41 9
65611673 30293221 97 76
600335772 653965500 46 14
990976871 492677168 89...

output:

865938730
669211888
32369129
423534516
430693030
471427702
75098499
426644230
32336255
110880687
162...

result:

ok 100 lines

Test #3:

score: 10
Accepted
time: 577ms
memory: 16772kb

input:

1000
548873691 264097921 7923 4513
118449254 247811930 6189 4973
102802244 867656765 9029 1781
66817...

output:

996443730
41197805
640964390
422993006
804926239
39882955
863682565
433331006
163321978
247751488
42...

result:

ok 1000 lines

Test #4:

score: 10
Accepted
time: 576ms
memory: 16768kb

input:

1000
725636584 614719405 8817 5740
770666961 692988784 9453 8578
218227240 534089367 5580 411
617769...

output:

917697439
869988616
468921165
802730271
378077568
905828741
681963857
203715928
691800306
525327379
...

result:

ok 1000 lines

Test #5:

score: 10
Accepted
time: 681ms
memory: 16772kb

input:

100000
247589871 928989407 78292 59427
115640346 541904953 96315 91790
874154292 296482294 82808 568...

output:

309166736
137291171
783755074
245560551
781570469
740708487
113707971
516120144
986742687
974985709
...

result:

ok 100000 lines

Test #6:

score: 10
Accepted
time: 678ms
memory: 16768kb

input:

100000
882477440 494944005 44617 38114
956228584 693051722 97135 83914
949547444 271076307 88095 673...

output:

502713144
746256124
407016403
761300376
496046961
653273118
593812032
679806789
381114906
452649568
...

result:

ok 100000 lines

Test #7:

score: 10
Accepted
time: 693ms
memory: 16768kb

input:

100000
882477440 494944005 44617 38114
956228584 693051722 97135 83914
949547444 271076307 88095 673...

output:

502713144
746256124
407016403
761300376
496046961
653273118
593812032
679806789
381114906
452649568
...

result:

ok 100000 lines

Test #8:

score: 10
Accepted
time: 683ms
memory: 16772kb

input:

100000
882477440 494944005 44617 38114
956228584 693051722 97135 83914
949547444 271076307 88095 673...

output:

502713144
746256124
407016403
761300376
496046961
653273118
593812032
679806789
381114906
452649568
...

result:

ok 100000 lines

Test #9:

score: 10
Accepted
time: 675ms
memory: 16768kb

input:

100000
654291012 317497736 98841 65237
824771283 107156088 44307 16912
622363193 457922825 80904 468...

output:

488484310
841436006
933472705
779836458
859160236
631909937
197120931
708321906
777372
14699220
5864...

result:

ok 100000 lines

Test #10:

score: 10
Accepted
time: 688ms
memory: 16768kb

input:

100000
654291012 317497736 98841 65237
824771283 107156088 44307 16912
622363193 457922825 80904 468...

output:

488484310
841436006
933472705
779836458
859160236
631909937
197120931
708321906
777372
14699220
5864...

result:

ok 100000 lines