QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#585306 | #9376. Game | yasdf123 | WA | 186ms | 3608kb | C++20 | 757b | 2024-09-23 20:15:42 | 2024-09-23 20:15:42 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
int mod=998244353;
int qpow(int n,int q) {
int x=1;
while(q>0) {
if(q%2==1) {
x=x*n%mod;
}
n=(n*n)%mod;
q/=2;
}
return x;
}
void run() {
int x,y;
int a0,a1,b;
cin>>x>>y>>a0>>a1>>b;
int p0=a0*qpow(a0+a1,mod-2)%mod,p1=a1*qpow(a0+a1,mod-2)%mod;
int ans=0,p=1;
while(x>0) {
if(x<=y) {
p=p*qpow(p0,y/x)%mod;
y=y%x;
if(y==0) {
ans+=p;
break;
}
}
int n1=x/y;
x=x%y;
if(x%y==0) {
n1--;
x=y;
}
ans=(ans+p*p0%mod*(1-qpow(p1,n1))%mod*qpow(1-p1,mod-2)%mod)%mod;
p=p*qpow(p1,n1)%mod;
}
cout<<ans<<"\n";
}
signed main() {
int t=1;
cin>>t;
while(t--) {
run();
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3560kb
input:
3 1 1 2 2 6 1 3 2 3 6 3 4 7 3 15
output:
499122177 910398850 220911476
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 186ms
memory: 3608kb
input:
100000 1 1000000000 12980050 128257807 266126484 1 1000000000 400255084 123438563 768881284 1000000000 1000000000 24563487 72082135 450057094 1 1000000000 56952077 40876000 193815114 1000000000 1000000000 82048274 239365585 326520865 1000000000 1 309821265 346013425 963168258 1 1 104158269 199365020...
output:
947058399 376449942 612621163 138416357 592200562 1044023733 870227707 169499045 1084640816 415694940 1045095709 951368934 426243016 864656779 750317399 922456360 486881524 824329239 198191519 189360084 966510181 512645443 695650039 703100783 550002158 1436714535 246877045 39876086 667870434 4051966...
result:
wrong answer 6th lines differ - expected: '45779380', found: '1044023733'