QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#758664 | #9627. 算术 | 5720226849# | AC ✓ | 2ms | 3712kb | C++14 | 2.4kb | 2024-11-17 19:17:05 | 2024-11-17 19:17:05 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define Yes cout << "Yes\n"
#define No cout << "No\n"
#define YES cout << "YES\n"
#define NO cout << "NO\n"
#define ls u << 1
#define rs u << 1 | 1
#define all(x) x.begin(),x.end()
#define i128 __int128
#define int long long
#define Genshin_Impact return
#define Starts 0
#define _o_o_ return
#define o_o_o return
inline int gcd(int a, int b) {return b > 0 ? gcd(b, a % b) : a;}
inline int lowbit(int x) {return x & (-x);}
int qmi(int a, int b, int mod){int res = 1;while(b) {if(b & 1) res = res * a % mod;a = a * a % mod;b >>= 1;}return res;}
// inline i128 read(){i128 x = 0, f = 1;char ch = getchar();while(ch < '0' || ch > '9'){if(ch == '-')f = -1;ch = getchar();}while(ch >= '0' && ch <= '9'){x = x * 10 + ch - '0';ch = getchar();}return x * f;}
// inline void print(i128 x){if(x < 0){putchar('-');x = -x;}if(x > 9)print(x / 10);putchar(x % 10 + '0');}
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<double, PII> PIII;
const int N = 5e5 + 10, logn = 21, inf = 1e18, mod = 998244353, M = 2e6 + 10;
const int P = 131;
#define ull unsigned long long
int a[N];
void solve()
{
// 总和相等,差值越小越大
for(int i = 1; i <= 9; i ++) cin >> a[i];
a[10] = 0;
// 差值越小1乘积越大
// 搞出一堆2出来即可
// 2 * 11肯定小于3 * 10
// x * 4 * 2 // x * 9
// x * 9 * 2 // x * 16
// 如果有2先变3
// 可以枚举多少个2变3
// 如果有多出的1,那就变2
if(a[2] >= a[1]) {
a[3] += a[1];
a[2] -= a[1];
a[1] = 0;
}
else {
a[3] += a[2];
a[1] -= a[2];
a[2] = 0;
a[3] += a[1] / 3;
a[1] %= 3;
if(a[1] == 2) a[2] ++;
else {
for(int i = 2; i <= 9; i ++)
if(a[i] > 0 && a[1] > 0) {
a[i + 1] ++;
a[i] --;
break;
}
}
}
int res = 1;
// for(int i = 1; i <= 10; i ++) cout << a[i] << ' ';
for(int i = 2; i <= 10; i ++)
for(int j = 1; j <= a[i]; j ++)
res = res * i % mod;
cout << res << '\n';
}
signed main()
{
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int t = 1;
cin >> t;
while (t--)
solve();
Genshin_Impact Starts;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3604kb
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: 0
Accepted
time: 2ms
memory: 3712kb
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:
376701872 321820208 765709043 819408880 639261805 521201354 7172464 780360907 240853384 151457742 298466126 416189734 124742738 161566750 493291429 481038778 409158325 951979430 783007793 438976523 440485591 163247072 78098984 275527515 308024444 168349368 423889166 168234582 827159852 914298923 465...
result:
ok 1000 lines
Test #3:
score: 0
Accepted
time: 1ms
memory: 3644kb
input:
1000 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 2 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0 0 0 0 0 1 0 0 1 0 0 0...
output:
1 2 3 4 5 6 7 8 9 2 3 4 5 6 7 8 9 10 4 6 8 10 12 14 16 18 9 12 15 18 21 24 27 16 20 24 28 32 36 25 30 35 40 45 36 42 48 54 49 56 63 64 72 81 53234520 78732 944784 17744840 53234520 688747536 141958720 19131876 4374 9726857 668738521 35489680 11664 79851780 8748 104630853 551437603 234594227 96996101...
result:
ok 1000 lines