QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#589938 | #9376. Game | mwh | WA | 103ms | 3728kb | C++20 | 966b | 2024-09-25 20:44:10 | 2024-09-25 20:44:12 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using i128 = __int128_t;
typedef long long ll;
typedef unsigned long long ULL;
typedef array<int,3> node;
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
const int INF = 0x3f3f3f3f;
const ll p1=131,p2=13331;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
const int mod = 998244353;
ll qmi(int a,int b){
ll res=1%mod,t=a;
while(b){
if(b&1)res=res*t%mod;
t=t*t%mod;
b>>=1;
}
return res;
}
ll f(int x,int y,int a,int b){
if(x==0)return 0;
return qmi(a,y/x)*((1-f(y%x,x,b,a)+mod)%mod)%mod;
}
void work(){
ll x,y;
cin>>x>>y;
ll a0,a1,b;
cin>>a0>>a1>>b;
ll c=a0+a1;
a0=a0*qmi(c,mod-2);
a1=a1*qmi(c,mod-2);
cout<<f(x,y,a0,a1)<<endl;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr), cout.tie(nullptr);
int t=1;
cin>>t;
while(t--){
work();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3716kb
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: 103ms
memory: 3728kb
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:
23409871 109354877 683273820 241464537 -642876456 241819930 866111085 -27984652 493632896 31644570 389088918 942959651 -433710537 -265382174 802636063 587183980 -69267389 346523045 -41028232 170484524 73605878 55001858 -544733033 996071424 851970839 95437381 659400395 182568424 -553127905 930884311 ...
result:
wrong answer 1st lines differ - expected: '947058399', found: '23409871'