QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#585553 | #9376. Game | cjl000 | WA | 0ms | 3640kb | C++23 | 1.6kb | 2024-09-23 21:13:10 | 2024-09-23 21:13:11 |
Judging History
answer
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<math.h>
#include<string.h>
#include<deque>
#include<string>
#include<queue>
#include<cstring>
#include<string>
#include<numeric>
#include<bitset>
#include<array>
#include<stack>
using namespace std;
#define lowbit(x) x & ( -x )
#define endl '\n'
#define itn long long
#define int long long
#define YES cout<<"YES"<<endl;
#define NO cout<<"NO"<<endl;
#define ull unsigned long long
#define bug cout<<"bug"<<endl;
//const int p = 131;
const ull hx = 13331;
int dx[6] = { 0,1,0,-1 };
int dy[6] = { 1,0,-1,0 };
const int N = 200003;
const int mod = 998244353;
int ksm(int a, int p)
{
int t = 1, tt = a % mod;
while (p)
{
if (p & 1)t = t * tt % mod;
tt = tt * tt % mod;
p >>= 1;
}
return t;
}
int dfs(int a, int b, int x, int y)
{
if (x > y)
{
return (1 - dfs(b, a, y, x)%mod + mod) % mod;
}
int res = ksm(a, (y + x - 1) / x);
if (y % x)
{
res += dfs(a, b, x - y % x, y % x) * b & ksm(a, y / x);
}
return res;
}
int x, y, a, b, sum;
void tt()
{
//快速幂 fz*ksm(fm,mod-2)
//求完逆元后的数可以相乘取得新的分数
//
cin >> x >> y >> a >> b >> sum;
sum = a + b;
a = a * ksm(sum, mod - 2) % mod, b = b * ksm(sum, mod - 2) % mod;
cout << dfs(a, b, x, y) << endl;
}
signed main()
{
std::ios::sync_with_stdio(false);
std::cin.tie(0);
std::cout.tie(0);
int t = 1;
cin >> t;
while (t--) {
tt();
}
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3640kb
input:
3 1 1 2 2 6 1 3 2 3 6 3 4 7 3 15
output:
499122177 910398850 755934165
result:
wrong answer 3rd lines differ - expected: '220911476', found: '755934165'