QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#584363 | #9376. Game | fantasy_xll | WA | 52ms | 3680kb | C++20 | 1020b | 2024-09-23 13:10:45 | 2024-09-23 13:10:46 |
Judging History
answer
//
//Created by xll.
//
#include<bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int,int> PII;
const int N = 200010;
const int inf=1e18;
const int mod=998244353;
int qmi(int a,int b)
{
int res=1%mod;
while(b)
{
if(b&1)res=res*a%mod;
a=a*a%mod;
b>>=1;
}
return res%mod;
}
int inv(int x)
{
return qmi(x,mod-2);
}
void calc(int x,int y,int px,int py,int &u,int &v)
{
if(!y)
{
u=1,v=0;
return;
}
int k=x/y;
int nu,nv;
calc(y,x%y,py,px,nv,nu);
int t=qmi(py,k);
u=(t*nu+1-t+mod)%mod;
v=t*nv%mod;
}
void solve()
{
int x,y,a,b,c;
cin>>x>>y>>a>>b>>c;
c=inv(a+b);
a=a*c,b=b*c;
int u,v;
calc(x,y,a,b,u,v);
cout<<u%mod<<'\n';
return;
}
signed main()
{
std::ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int T;
cin >> T;
while(T --)
{
solve();
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3680kb
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: 52ms
memory: 3656kb
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:
7848007 419180552 612621163 36374442 592200562 230025554 870227707 169499045 909680381 415694940 337966750 252126 426243016 864656779 750317399 608281462 486881524 285134565 198191519 189360084 966510181 512645443 695650039 362360023 550002158 541657863 832829770 335852921 667870434 111027908 593590...
result:
wrong answer 1st lines differ - expected: '947058399', found: '7848007'