QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#582189#9376. Gamebu_moWA 0ms3836kbC++201.3kb2024-09-22 15:36:032024-09-22 15:36:03

Judging History

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

  • [2024-09-22 15:36:03]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3836kb
  • [2024-09-22 15:36:03]
  • 提交

answer

#include <bits/stdc++.h>

const int mod = 998244353;

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

int T, x, y, fz, fm;

int solve(int x, int y, int cnt1, int cnt2) {
  std::cout << x << " " << y << " " << cnt1 << " " << cnt2 << '\n';
  if (y == 0) return (1ll * qpow(fz, cnt1) * qpow(qpow(fm, cnt1), mod - 2) % mod) * (1ll * qpow(fm - fz, cnt2) * qpow(qpow(fm, cnt2), mod - 2) % mod) % mod;
  if (x == 0) return 0;
  if (x >= y) {
    int ad = (x - 1) / y;
    int prt1 = (1ll * qpow(fz, cnt1 + 1) * qpow(qpow(fm, cnt1 + 1), mod - 2) % mod) * (1ll * qpow(fm - fz, cnt2) * qpow(qpow(fm, cnt2), mod - 2) % mod) % mod;
    int prt2 = (1ll * fm * qpow(fz, mod - 2) % mod - 1ll * qpow(fm - fz, ad + 1) * qpow(1ll * fz * qpow(fm, ad) % mod, mod - 2) % mod + mod) % mod;
    return (1ll * prt1 * prt2 % mod + solve(x % y, x, cnt1, cnt2 + ad)) % mod;
  } else return solve(x, y % x, cnt1 + y / x, cnt2);
}

int main() {
  scanf("%d", &T);
  while (T--) {
    int tmp;
    scanf("%d %d", &x, &y);
    scanf("%d %d %d", &fz, &fm, &tmp);
    fm += fz;
    if (fz == 0) puts("0");
    else printf("%d\n", solve(x, y, 0, 0));
  }
  return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3836kb

input:

3
1 1
2 2 6
1 3
2 3 6
3 4
7 3 15

output:

1 1 0 0
0 1 0 0
499122177
1 3 0 0
1 0 3 0
910398850
3 4 0 0
3 1 1 0
0 3 1 2
220911476

result:

wrong answer 1st lines differ - expected: '499122177', found: '1 1 0 0'