QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#584339#9376. GameniolleML 0ms3744kbC++201.0kb2024-09-23 12:48:382024-09-23 12:48:39

Judging History

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

  • [2024-09-23 12:48:39]
  • 评测
  • 测评结果:ML
  • 用时:0ms
  • 内存:3744kb
  • [2024-09-23 12:48:38]
  • 提交

answer

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define dwn(i,a,b) for(int i=a;i>=b;i--)
#define lowbit(x) (x&(-x))
#define MAXN 152501
#define int long long
#define mp(x,y) make_pair(x,y)
using namespace std;
typedef long long ll;
inline int read(){
	int x=0,f=1;
	char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-') f=-1; ch=getchar();}
	while('0'<=ch && ch<='9') x=(x<<1)+(x<<3)+ch-'0',ch=getchar();
	return x*f;
}
const int mod = 998244353;
int p0,p1;
int ksm(int x,int y){
	int res = 1;
	while(y){
		if(y&1) res = res * x % mod;
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
ll wk(int x,int y){
	if(x == y) return p0;
	if(x < y){
		return p0 * wk(x,y-x) % mod;
	}
	else{
		return (p0 + p1 * wk(x-y,y)) % mod;
	}
}
int x,y,a0,a1,b0;
signed main(){
	int T = read();
	while(T--){
		x = read(); y = read();
		a0 = read(); a1 = read(); b0 = read();
		b0 = (a0 + a1) % mod;
		p0 = a0 * ksm(b0,mod-2) % mod;
		p1 = a1 * ksm(b0,mod-2) % mod;
		printf("%lld\n",wk(x,y));
	}
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3744kb

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
Memory Limit Exceeded

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:


result: