QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#585913 | #9376. Game | wlh | WA | 183ms | 3552kb | C++17 | 1.2kb | 2024-09-23 22:54:23 | 2024-09-23 22:54:23 |
Judging History
answer
#include <bits/stdc++.h>
#define ll long long
using namespace std;
long long M=998244353;
ll ksm(ll a, ll b){
ll res = 1;
while(b) {
if(b & 1) //判断b的二进制在此位是否为1
res = res * a % M;
a = a * a % M; //下一位的a的值
b >>= 1;
}
return res;
}
long long mod(long long a,long long b){
return a * ksm(b, M - 2) % M;
}
int main() {
int all;
cin>>all;
while(all--){
ll x,y,a,b,c;
cin>>x>>y;
cin>>a>>b>>c;
c=a+b;
//fenshu sum={1,1};
long long SUM=1;
while(y!=0&&x!=0){
if(x>y){
ll k1=ksm(c,x/y);
ll k2=ksm(b,x/y);
SUM*=mod((k1-k2),k1);
SUM%=M;
x-=x/y*y;
continue;
}
// cout<<sum.son<<' '<<sum.mon<<endl;
if(y==0||x==0) break;
if(x<y){
ll k1=ksm(c,y/x);
ll k2=ksm(a,y/x);
//sum=cheng(sum,{k2,k1});
SUM*=mod(k2,k1);
SUM%=M;
y-=y/x*x;
continue;
}
if(y==0||x==0) break;
if(x==y){
//sum=cheng(sum,{a,c});
SUM*=mod(a,c);
SUM%=M;
break;
}
}
// cout<<a<<' '<<c<<endl;
// cout<<sum.son<<' '<<sum.mon<<endl;
cout<<SUM<<endl;
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3552kb
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
Wrong Answer
time: 183ms
memory: 3532kb
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 -911847890 415694940 -951392997 951368934 426243016 864656779 750317399 922456360 486881524 824329239 198191519 189360084 966510181 512645443 695650039 -295143570 550002158 438470182 246877045 39876086 667870434 405196653...
result:
wrong answer 9th lines differ - expected: '86396463', found: '-911847890'