QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#745265 | #9376. Game | JZYZ# | WA | 67ms | 3876kb | C++14 | 889b | 2024-11-14 08:50:45 | 2024-11-14 08:50:45 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std ;
typedef long long LL ;
const int N = 1e5+10 ;
#define mod 998244353
inline LL qpow(LL a,LL b)
{
LL res=1;
while(b)
{
if(b&1)res=res*a%mod;
a=a*a%mod;
b>>=1;
}
return res;
}
int x , y , a0 , a1 , b ;
LL p1 , p2 ;
LL calc( LL x , LL y )
{
if( x == 0 ) return 0 ;
if( y == 0 ) return 1 ;
LL res=0 ;
if( x >= y ) {
int tim = x/y ;
res=(res+calc(x%y,y)*qpow(p2,tim)%mod+1-qpow(p2,tim)+mod)%mod;
}
else if( x < y ) res+=calc(x,y%x)*qpow(p1,y/x)%mod ;
return res;
}
void solve()
{
scanf("%d%d%d%d%d" , &x , &y , &a0 , &a1 , &b ) ;
p1 = (a0+(b-a0-a1)*a0%mod*qpow(a0+a1,mod-2))%mod*qpow(b,mod-2)%mod ;
p2 = (1-p1+mod)%mod ;
// printf("%lld %lld\n" , p1 , p2 ) ;
printf("%lld\n" , calc(x,y) ) ;
}
int main()
{
int t ;
scanf("%d" , &t ) ;
while( t -- ) solve() ;
return 0 ;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3876kb
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: 67ms
memory: 3752kb
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:
142797998 515183271 702588755 372205619 286565743 975165685 464415188 988930242 767998944 659553873 189152803 382531642 177828670 841314742 230807931 319564789 983843465 936388925 58511184 331906993 455163781 828594567 984640282 894837713 724502251 343099354 357962764 633055247 888172842 712593287 2...
result:
wrong answer 1st lines differ - expected: '947058399', found: '142797998'