QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#787905#9627. 算术masttf#WA 3ms3812kbC++201.5kb2024-11-27 15:12:142024-11-27 15:12:19

Judging History

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

  • [2024-11-27 15:12:19]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3812kb
  • [2024-11-27 15:12:14]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
#define dbg(x...) \
do{ \
	cout << #x << " -> "; \
	err(x); \
}while(0)
void err(){
	cout << endl;
}
template<class T, class ...Ts>
void err(T arg, Ts ...args){
	cout << fixed << setprecision(10) << arg << ' ';
	err(args...);
}

const int mod = 998244353;

void solve(){
	vector <int> a(15);
	for (int i = 1;i <= 9;i++) cin >> a[i];
	if (a[1] <= a[2]) {
		a[3] += a[1];
		a[1] = 0;
		a[2] -= a[1];
		int ans = 1;
		for (int i = 1;i <= 10;i++) {
			for (int j = 1;j <= a[i];j++) {
				ans = (ans * i);
				ans %= mod;
			}
		}
		cout << ans << '\n';
	}
	else {
		int ans = 1;
		int dis = a[1] - a[2];
		if (dis % 3 == 0) {
			a[3] += a[2];
			a[2] = 0;
			a[3] += dis / 3;
			a[1] = 0;
		}
		else if (dis % 3 == 1) {
			a[3] += a[2];
			a[2] = 0;
			a[3] += dis / 3;
			a[1] = 0;
			if (a[3]) {
				a[4]++;
				a[3]--;
			}
			else {
				int ok = 0;
				for (int j = 2;j <= 9;j++) {
					if (a[j]) {
						a[j]--;
						a[j + 1]++;
						ok = 1;
						break;
					}
				}
				if (!ok) a[1] = 1;
			}
		}
		else {
			a[3] += a[2];
			a[2] = 0;
			a[3] += dis / 3;
			a[1] = 0;
			a[2]++;
		}
		for (int i = 1;i <= 10;i++) {
			for (int j = 1;j <= a[i];j++) {
				ans = (ans * i);
				ans %= mod;
			}
		}
		cout << ans << '\n';
	}
	return ;
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t = 1;
	 cin >> t;
	while(t--)solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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
143532368

result:

ok 7 lines

Test #2:

score: -100
Wrong Answer
time: 3ms
memory: 3620kb

input:

1000
22 80 50 23 35 71 81 70 96
40 33 36 2 51 52 96 5 32
56 35 85 13 58 80 26 14 31
60 21 8 19 79 5 94 44 33
85 55 10 59 76 98 28 22 69
14 72 40 14 100 68 5 18 69
95 42 51 0 32 97 37 34 85
54 33 18 40 34 10 72 72 68
81 47 80 23 23 68 40 3 71
58 7 36 79 89 83 5 68 16
30 3 82 79 35 28 30 55 88
17 86 2...

output:

971495748
321820208
765709043
819408880
639261805
380788374
7172464
780360907
240853384
151457742
298466126
759900810
124742738
751026627
493291429
416032026
409158325
951979430
825701006
422909906
440485591
163247072
78098984
421935223
308024444
168349368
423889166
405465710
827159852
914298923
465...

result:

wrong answer 1st lines differ - expected: '376701872', found: '971495748'