ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#204757 | #3626. 概率计算 | BXW | 100 | 132ms | 1196kb | C++ | 603b | 2024-06-09 10:00:29 | 2024-06-09 12:02:19 |
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int mod=1000000007;
int n,p,q,d,px,inv;
int kasumi(int x,int y){
int re=1;
while(y){
if(y&1) re=re*x%mod;
y>>=1;
x=x*x%mod;
}
return re;
}
signed main(){
cin>>n>>p>>q;
int g=__gcd(p,q);
p/=g,q/=g;
p=q-p;
if(q==2*p) d=kasumi(n,mod-2);
else d=(q+mod-2*p%mod)%mod*kasumi(q-p,n-1)%mod*kasumi((kasumi(q-p,n)+mod-kasumi(p,n))%mod,mod-2)%mod;
inv=kasumi(q-p,mod-2);
for(int i=1;i<=n;i++){
px=(px+d)%mod;
cout<<px<<" ";
d=d*p%mod*inv%mod;
}
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 10
Accepted
time: 0ms
memory: 1196kb
input:
2 973073937 999758391
output:
382714835 1
result:
ok single line: '382714835 1 '
Test #2:
score: 10
Accepted
time: 0ms
memory: 1192kb
input:
3 365477961 916551500
output:
502567110 284127562 1
result:
ok single line: '502567110 284127562 1 '
Test #3:
score: 10
Accepted
time: 0ms
memory: 1196kb
input:
299 1 2
output:
441471575 882943150 324414718 765886293 207357861 648829436 90301004 531772579 973244154 414715722 8...
result:
ok single line: '441471575 882943150 324414718 ...75585290 117056858 558528433 1 '
Test #4:
score: 10
Accepted
time: 0ms
memory: 1196kb
input:
298 1 2
output:
265100673 530201346 795302019 60402685 325503358 590604031 855704704 120805370 385906043 651006716 9...
result:
ok single line: '265100673 530201346 795302019 ...04697989 469798662 734899335 1 '
Test #5:
score: 10
Accepted
time: 0ms
memory: 1192kb
input:
300 753850787 766896585
output:
759172300 794989483 298082840 772416102 992992517 498473273 537468571 717895255 309938428 87710480 9...
result:
ok single line: '759172300 794989483 298082840 ...95226663 968970710 101445994 1 '
Test #6:
score: 10
Accepted
time: 0ms
memory: 1196kb
input:
299 847729699 865235904
output:
536954675 858661352 666905805 760056224 731385885 488079853 900124555 517448601 469188960 640714011 ...
result:
ok single line: '536954675 858661352 666905805 ...08832697 731788147 203623632 1 '
Test #7:
score: 10
Accepted
time: 1ms
memory: 1192kb
input:
298 803230088 887298490
output:
254886050 166570397 615685083 699726315 907262083 835292727 887332047 755218278 128129081 285779446 ...
result:
ok single line: '254886050 166570397 615685083 ...82582015 739421450 896169531 1 '
Test #8:
score: 10
Accepted
time: 34ms
memory: 1196kb
input:
500000 242253657 742311700
output:
873056060 153147128 516367397 745999010 682815667 668319169 546803226 971263033 492810120 522516088 ...
result:
ok single line: '873056060 153147128 516367397 ...78641368 472470703 156125084 1 '
Test #9:
score: 10
Accepted
time: 45ms
memory: 1196kb
input:
499999 926824122 947703016
output:
97940792 372292291 473100395 112083731 331585835 161720951 797940017 450127708 625687708 173690184 5...
result:
ok single line: '97940792 372292291 473100395 1...72230663 307607479 939929919 1 '
Test #10:
score: 10
Accepted
time: 52ms
memory: 1192kb
input:
499998 534420093 818113917
output:
71495630 454243883 745549062 513163061 178770645 773603674 424486391 655895470 527258923 484527216 8...
result:
ok single line: '71495630 454243883 745549062 5...47262765 178322731 104130412 1 '
Extra Test:
score: 0
Extra Test Passed