QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#789598 | #9627. 算术 | NULL_SF | WA | 0ms | 3568kb | C++17 | 1018b | 2024-11-27 21:03:12 | 2024-11-27 21:03:18 |
Judging History
answer
#include <iostream>
#define int long long
using namespace std;
const int mod=998244353;
int a[10];
int quick_pow(int base,int index)
{
int ans=1,tmp=base;
while(index){
if(index&1){
ans*=tmp;
ans%=mod;
}
tmp*=tmp;
tmp%=mod;
index>>=1;
}
return ans;
}
int get_inv(int x)
{
return quick_pow(x,mod-2);
}
void solve()
{
int ans=1,mini=10;
for(int i=1;i<=9;i++){
cin>>a[i];
if(a[i] && i>1) mini=min(mini,i);
if(i>2) ans*=quick_pow(i,a[i]),ans%=mod;
}
if(a[2]<=a[1])
{
ans*=quick_pow(3,a[2]),ans%=mod;
a[1]-=a[2];
while(a[1]>=3){
ans*=3;
ans%=mod;
a[1]-=3;
}
if(a[1]==1) ans=(ans==1)?1:ans*get_inv(mini)*(mini+1),ans%=mod;
else if(a[1]==2) ans*=2,ans%=mod;
}
else
{
ans*=quick_pow(3,a[2]),ans%=mod;
a[2]-=a[1];
ans*=quick_pow(2,a[2]),ans%=mod;
}
cout<<ans<<'\n';
return;
}
signed main()
{
int t;
cin>>t;
while(t--){
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3568kb
input:
7 5 3 0 0 0 0 0 0 0 4 1 1 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 2 99 88 77 66 55 44 33 22 11 100 90 80 70 60 50 40 30 20
output:
54 108 1 10 90 90553232 161473914
result:
wrong answer 7th lines differ - expected: '143532368', found: '161473914'