QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#590718#9376. GameChief_NingRE 0ms0kbC++141.0kb2024-09-26 10:29:482024-09-26 10:29:49

Judging History

你现在查看的是最新测评结果

  • [2024-09-26 10:29:49]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-09-26 10:29:48]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

using u64 = unsigned long long;
using u32 = unsigned int;
using i64 = long long;

mt19937_64 rnd(random_device{}());

const int mod = 998244353;
const int N = 3e5 + 5;
const int M = 2e6 + 5;

int n, m, s, t;

i64 fastpow(i64 a, int n) {
	i64 res = 1;
	a %= mod;
	while(n) {
		if(n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

i64 inv(i64 a) {
	return fastpow(a, mod - 2);
}

int f(int x, int y, int pa, int pb) {
	return fastpow(pa, y / x) * (1 - f(y % x, x, pb, pa) + mod) % mod;
}

void RuinGuard(int tc)
{
	int x, y;
	
	cin >> x >> y;
	 
	int a, b, c;
	
	cin >> a >> b >> c;
	
	int pa = a * inv(a + b) % mod;
	int pb = b * inv(a + b) % mod; 
	
	return cout << f(x, y, pa, pb) << '\n', void();
}

signed main()
{ 
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    
    int testcase = 1;
	cin >> testcase;
	
    for(int tc = 1; tc <= testcase; tc++) {
    	RuinGuard(tc);
	}

    return 0;
}

详细

Test #1:

score: 0
Runtime Error

input:

3
1 1
2 2 6
1 3
2 3 6
3 4
7 3 15

output:


result: