QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#751018#9627. 算术Dylan114514RE 0ms0kbC++14967b2024-11-15 16:46:242024-11-15 16:46:26

Judging History

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

  • [2024-11-15 16:46:26]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-11-15 16:46:24]
  • 提交

answer

#include <bits/stdc++.h>
#include <iostream>

using namespace std;
#define int long long
const int mod = 998244353;

int qpow(int a, int b) {
  a %= mod;
  int res = 1;
  while (b) {
    if (b & 1) {
      res = (res * a) % mod;
    }
    a = (a * a) % mod;
    b >>= 1;
  }
  return res % mod;
}

const int N = 0x3f3f3f3f;

int a[N], ans;

void solve() {
  memset(a, 0, sizeof(a));
  ans = 1;
  for (int i = 1; i <= 9; ++i)
    cin >> a[i];
  while (a[1] >= 2 && a[1] > a[2]) {
    a[1] -= 2, a[2]++;
  }
  for (int i = 2; i <= 9; ++i) {
    if (a[1] == 0)
      break;
    int ad = min(a[1], a[i]);
    a[1] -= ad, a[i] -= ad, a[i + 1] += ad;
  }
  for (int i = 1; i <= 10; ++i) {
    ans %= mod;
    if (a[i])
      ans *= (qpow(i, a[i])) % mod;
  }
  cout << ans << endl;
}

signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--)
    solve();
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Runtime Error

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:


result: