QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#580775 | #9376. Game | zy123 | WA | 71ms | 3676kb | C++14 | 3.0kb | 2024-09-21 23:47:40 | 2024-09-21 23:47:45 |
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 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;
ll ant=b*inv(a+b)%mod;
ant=ksm_mod(ant,cnt,mod);
ant=((1ll-ant)%mod+mod)%mod;
return ant%mod;
}
else
{
ll cnt=y/x;
if(y%x)
{
cnt++;
}
ll ans=0;
ll ant=a*inv(a+b)%mod;
ans=ksm_mod(ant,cnt,mod)%mod;
ans=ans+ksm_mod(ant,cnt-1,mod)*gcd(x-y%x,y%x)%mod*b%mod*inv(a+b)%mod;
return ans%mod;
}
}
void solve()
{
ll x,y;
cin >> x >> y;
cin >> a >> b >> c;
cout << gcd(x,y)%mod << "\n";
}
signed main()
{
IOS;
int t=1;
cin >> t;
while(t--)
{
solve();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3648kb
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: 66ms
memory: 3544kb
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: 71ms
memory: 3676kb
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:
600365044 245280510 887021893 231907167 361325009 574117564 238993273 622001469 766432647 609821102 841011161 770237495 679387554 424321263 923316750 359292771 147637794 959207844 298465101 934093433 523854806 313916280 20843134 724894048 271297401 458373710 368934853 997326947 830797036 249283340 5...
result:
wrong answer 1st lines differ - expected: '623291477', found: '600365044'