QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#580782 | #9376. Game | zy123 | WA | 58ms | 3700kb | C++14 | 3.1kb | 2024-09-21 23:50:37 | 2024-09-21 23:50:38 |
Judging History
answer
//
// main.cpp
// zy_123
//
// Created by 燃烧星空 on 2024/1/20.
//
//
//#include<bits/stdc++.h>
#include<iostream>
#include<map>
#include<unordered_map>
#include<set>
#include<cmath>
#include<vector>
#include<queue>
#include<deque>
#include<string>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<unordered_set>
#include<math.h>
#include<stack>
#include<stdint.h>
#include<bitset>
#include<fstream>
#include<random>
#include<chrono>
#include<time.h>
#define IOS cin.tie(0) -> sync_with_stdio(false), cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=2e5+5;
const int M=5e5+5;
const int inf=0x3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define lc p<<1
#define rc p<<1|1
#define lb(x) (x&(-x))
#define endl "\n"
double pai = acos(-1);
//const ll mod=1e9+7;
const ll mod=998244353;
#define int ll
//__int128 read_128()//c++20(64)可用
//{
// __int128 x=0,f=1;char ch = getchar();
// while(ch < '0' || ch > '9'){if(ch == '-') f=-1;ch=getchar();}
// while(ch >= '0' && ch <= '9'){x = x * 10 + ch - '0';ch=getchar();}
// return x*f;
//}
//void print_128(__int128 x)
//{
// if(x<0){putchar('-');x=-x;}
// if(x>9)print_128(x/10);
// putchar(x % 10 + '0');
//}
//int idx=1,nxt[M*2],dian[M*2],h[N];
//ll quan[M*2];
////ll rong[M*2];
//int cur[N];
//void add(int a,int b,ll c)
//{
// dian[++idx]=b;quan[idx]=c;
//// rong[idx]=c;
// nxt[idx]=h[a];h[a]=idx;
//
// dian[++idx]=a;quan[idx]=0;
//// rong[idx]=0;
// nxt[idx]=h[b];h[b]=idx;
//}
//mt19937_64 rnd(chrono::steady_clock::now().time_since_epoch().count());
//ll ksm(ll a,ll b){ll sum=1;while(b){if(b&1){sum*=a;}a*=a;b>>=1;}return sum;}
ll ksm_mod(ll a,ll b,ll p){ll sum=1;while(b){if(b&1){sum=sum*a%p;}a=a*a%p;b>>=1;}return sum%p;}
//ll gsc(ll a,ll b,ll p){ll sum=0;while(b){if(b&1){sum=(sum+a)%p;}a=a*2%p;b>>=1;}return sum%p;}
//ll quick_mul(ll x,ll y,ll p){ll z=(long double)x/p*y;ll res=(ull)x*y-(ull)z*p;return (res+p)%p;}
ll n,m,q;
ll a,b,c;
ll px,py;
ll inv(ll a)
{
return ksm_mod(a,mod-2,mod)%mod;
}
ll gcd(ll x,ll y)
{
// cout << x << " " << y << "\n";
if(y<=0||x<=0)
{
return 0;
}
if(x>y)
{
ll cnt=x/y;
if(x%y)
{
cnt++;
}
ll ant=ksm_mod(py,cnt,mod);
ant=((1ll-ant)%mod+mod)%mod;
return ant%mod;
}
else
{
ll cnt=y/x;
if(y%x)
{
cnt++;
}
ll ans=0;
ans=ksm_mod(px,cnt,mod)%mod;
ans=ans+ksm_mod(px,cnt-1,mod)*gcd(x-y%x,y%x)%mod*py%mod;
return ans%mod;
}
}
void solve()
{
ll x,y;
cin >> x >> y;
cin >> a >> b >> c;
px=a%mod*inv(a+b)%mod;
py=b%mod*inv(a+b)%mod;
cout << gcd(x,y)%mod << "\n";
}
signed main()
{
IOS;
int t=1;
cin >> t;
while(t--)
{
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3700kb
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: 0
Accepted
time: 47ms
memory: 3584kb
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 45779380 870227707 169499045 86396463 415694940 46851356 951368934 426243016 864656779 750317399 922456360 486881524 824329239 198191519 189360084 966510181 512645443 695650039 703100783 550002158 438470182 246877045 39876086 667870434 405196653 5935...
result:
ok 100000 lines
Test #3:
score: -100
Wrong Answer
time: 58ms
memory: 3568kb
input:
100000 167959139 481199252 18199423 25950409 149762920 773386884 579721198 16629525 28339910 152155823 2087506 268792718 43528658 6471925 90197530 691952768 717268783 516613092 94328992 743662288 45277106 856168102 309821265 346013425 963168258 279198849 527268921 30167950 166388455 577970339 140515...
output:
258345903 976140587 732487542 230388145 283776079 261827493 404986806 93163415 210461266 840800607 92044973 12421661 134705558 535822717 364978245 339210323 741165341 839204991 584843748 253380221 342820229 26852086 790567388 500817009 936543372 337783624 45460640 30290166 416596631 281681755 357256...
result:
wrong answer 1st lines differ - expected: '623291477', found: '258345903'