QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#592937 | #9376. Game | zero_orez | WA | 151ms | 3656kb | C++14 | 764b | 2024-09-27 10:16:09 | 2024-09-27 10:16:10 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int mod=998244353;
int T,x,y,a,b,c;
int q_mi(int p,int q)
{
int sm=1;
while(q)
{
if(q&1) sm=sm*p%mod;
p=p*p%mod;
q>>=1;
}
return sm%mod;
}
int inv(int x)
{
return (q_mi(x,mod-2)%mod+mod)%mod;
}
signed main()
{
cin>>T;
while(T--)
{
cin>>x>>y>>a>>b>>c;
int p=a*q_mi(a+b,mod-2);
int q=b*q_mi(a+b,mod-2);
int as=0,ls=1;
while(x!=y)
{
if(x>y)
{
int t=(x-1)/y;
as=((as+ls*(1-q_mi(q,t))+mod)%mod);
ls=(ls*q_mi(q,t)%mod+mod)%mod;
x-=t*y;
}
else
{
int t=(y-1)/x;
ls=(ls%mod*q_mi(p,t)%mod+mod)%mod;
y-=t*x;
}
}
as=(as+ls*p%mod+mod)%mod;
cout<<as<<endl;
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3656kb
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: 151ms
memory: 3572kb
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:
57660923 349699982 612621163 715857038 592200562 76520153 870227707 169499045 667597353 415694940 140987510 464905228 426243016 864656779 750317399 268631494 486881524 16020688 198191519 189360084 966510181 512645443 695650039 709706254 550002158 616407070 458326158 551455286 667870434 918218440 593...
result:
wrong answer 1st lines differ - expected: '947058399', found: '57660923'