QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#587539 | #9376. Game | DING | Compile Error | / | / | C++17 | 2.3kb | 2024-09-24 20:34:32 | 2024-09-24 20:34:33 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int mod=998244353;
int quick(int a,int n){
int res=1;
while(n){
if(n&1)res=res*a%mod;
a=a*a%mod;
n>>=1;
}
return res%mod;
}
int x,y,a0,a1,b,ni;
int dfs(int x,int y,int ans ){
if(x==0)return 0;
if(y==0)return 1;
if(x==y)return ans%mod+a0*ni%mod;
if(x>y){
int ci=x/y;
x=x%y;
if(x==0)swap(x,y);
ans=ans%mod+(quick(a0+a1,ci)-quick(a1,ci)+mod)%mod*quick(ni,ci)%mod*dfs(x,y,ans)%mod;
// cout<<ans<<"!"<<endl;
// return ans;
}
else if(x<y){
int ci=y/x;
y=y%x;
ans=ans%mod+quick(a0,ci)*quick(ni,ci)%mod*dfs(x,y,ans)%mod;
// cout<<ans<<"?"<<endl;
// return ans;
}
return ans;
}
void solve(){
cin>>x>>y>>a0>>a1>>b;
int tem=a1+a0;
a1=a1/__gcd(tem,a1);
a0=a0/__gcd(tem,a0);
ni=quick(a0+a1,mod-2);
int ans=dfs(x,y,0);
cout<<ans%mod<<endl;
}
signed main(){
int t;
cin>>t;
// cout<<quick(2,10)<<endl;
while(t--){
solve();
}
return 0;
}#include<bits/stdc++.h>
#define int long long
using namespace std;
const int mod=998244353;
int quick(int a,int n){
int res=1;
while(n){
if(n&1)res=res*a%mod;
a=a*a%mod;
n>>=1;
}
return res%mod;
}
int x,y,a0,a1,b,ni;
int dfs(int x,int y,int ans ){
if(x==0)return 0;
if(y==0)return 1;
if(x==y)return ans%mod+a0*ni%mod;
if(x>y){
int ci=x/y;
x=x%y;
if(x==0)swap(x,y);
ans=ans%mod+(quick(a0+a1,ci)-quick(a1,ci)+mod)%mod*quick(ni,ci)%mod*dfs(x,y,ans)%mod;
// cout<<ans<<"!"<<endl;
// return ans;
}
else if(x<y){
int ci=y/x;
y=y%x;
ans=ans%mod+quick(a0,ci)*quick(ni,ci)%mod*dfs(x,y,ans)%mod;
// cout<<ans<<"?"<<endl;
// return ans;
}
return ans;
}
void solve(){
cin>>x>>y>>a0>>a1>>b;
int tem=a1+a0;
a1=a1/__gcd(tem,a1);
a0=a0/__gcd(tem,a0);
ni=quick(a0+a1,mod-2);
int ans=dfs(x,y,0);
cout<<ans%mod<<endl;
}
signed main(){
int t;
cin>>t;
// cout<<quick(2,10)<<endl;
while(t--){
solve();
}
return 0;
}
详细
answer.code:54:2: error: stray ‘#’ in program 54 | }#include<bits/stdc++.h> | ^ answer.code:54:3: error: ‘include’ does not name a type 54 | }#include<bits/stdc++.h> | ^~~~~~~ answer.code:57:11: error: redefinition of ‘const long long int mod’ 57 | const int mod=998244353; | ^~~ answer.code:4:11: note: ‘const long long int mod’ previously defined here 4 | const int mod=998244353; | ^~~ answer.code:58:5: error: redefinition of ‘long long int quick(long long int, long long int)’ 58 | int quick(int a,int n){ | ^~~~~ answer.code:5:5: note: ‘long long int quick(long long int, long long int)’ previously defined here 5 | int quick(int a,int n){ | ^~~~~ answer.code:67:5: error: redefinition of ‘long long int x’ 67 | int x,y,a0,a1,b,ni; | ^ answer.code:14:5: note: ‘long long int x’ previously declared here 14 | int x,y,a0,a1,b,ni; | ^ answer.code:67:7: error: redefinition of ‘long long int y’ 67 | int x,y,a0,a1,b,ni; | ^ answer.code:14:7: note: ‘long long int y’ previously declared here 14 | int x,y,a0,a1,b,ni; | ^ answer.code:67:9: error: redefinition of ‘long long int a0’ 67 | int x,y,a0,a1,b,ni; | ^~ answer.code:14:9: note: ‘long long int a0’ previously declared here 14 | int x,y,a0,a1,b,ni; | ^~ answer.code:67:12: error: redefinition of ‘long long int a1’ 67 | int x,y,a0,a1,b,ni; | ^~ answer.code:14:12: note: ‘long long int a1’ previously declared here 14 | int x,y,a0,a1,b,ni; | ^~ answer.code:67:15: error: redefinition of ‘long long int b’ 67 | int x,y,a0,a1,b,ni; | ^ answer.code:14:15: note: ‘long long int b’ previously declared here 14 | int x,y,a0,a1,b,ni; | ^ answer.code:67:17: error: redefinition of ‘long long int ni’ 67 | int x,y,a0,a1,b,ni; | ^~ answer.code:14:17: note: ‘long long int ni’ previously declared here 14 | int x,y,a0,a1,b,ni; | ^~ answer.code:69:5: error: redefinition of ‘long long int dfs(long long int, long long int, long long int)’ 69 | int dfs(int x,int y,int ans ){ | ^~~ answer.code:16:5: note: ‘long long int dfs(long long int, long long int, long long int)’ previously defined here 16 | int dfs(int x,int y,int ans ){ | ^~~ answer.code:90:6: error: redefinition of ‘void solve()’ 90 | void solve(){ | ^~~~~ answer.code:37:6: note: ‘void solve()’ previously defined here 37 | void solve(){ | ^~~~~ answer.code:99:8: error: redefinition of ‘int main()’ 99 | signed main(){ | ^~~~ answer.code:46:8: note: ‘int main()’ previously defined here 46 | signed main(){ | ^~~~