QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#789598#9627. 算术NULL_SFWA 0ms3568kbC++171018b2024-11-27 21:03:122024-11-27 21:03:18

Judging History

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

  • [2024-11-27 21:03:18]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3568kb
  • [2024-11-27 21:03:12]
  • 提交

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;
}

詳細信息

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'