結果

問題 No.2406 Difference of Coordinate Squared
ユーザー 👑 amentorimaruamentorimaru
提出日時 2023-06-30 13:22:04
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 979 bytes
コンパイル時間 791 ms
コンパイル使用メモリ 122,228 KB
実行使用メモリ 7,576 KB
最終ジャッジ日時 2023-10-19 00:15:04
合計ジャッジ時間 13,123 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 WA -
testcase_02 AC 38 ms
7,072 KB
testcase_03 RE -
testcase_04 AC 847 ms
7,072 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 178 ms
5,028 KB
testcase_07 AC 10 ms
4,500 KB
testcase_08 AC 13 ms
5,820 KB
testcase_09 TLE -
testcase_10 AC 422 ms
6,876 KB
testcase_11 AC 15 ms
6,348 KB
testcase_12 AC 18 ms
6,612 KB
testcase_13 TLE -
testcase_14 AC 178 ms
6,612 KB
testcase_15 AC 188 ms
7,072 KB
testcase_16 AC 310 ms
5,556 KB
testcase_17 AC 1 ms
4,348 KB
testcase_18 RE -
testcase_19 AC 17 ms
6,612 KB
testcase_20 AC 544 ms
6,876 KB
testcase_21 AC 20 ms
5,292 KB
testcase_22 RE -
testcase_23 AC 1,485 ms
7,072 KB
testcase_24 AC 283 ms
4,348 KB
testcase_25 RE -
testcase_26 AC 2 ms
4,348 KB
testcase_27 RE -
testcase_28 AC 1 ms
4,348 KB
testcase_29 AC 2 ms
4,348 KB
testcase_30 AC 1 ms
4,348 KB
testcase_31 AC 2 ms
4,348 KB
testcase_32 AC 2 ms
4,348 KB
testcase_33 WA -
testcase_34 AC 2 ms
4,348 KB
testcase_35 AC 2 ms
4,348 KB
testcase_36 AC 2 ms
4,348 KB
testcase_37 AC 1 ms
4,348 KB
testcase_38 AC 2 ms
4,348 KB
testcase_39 RE -
testcase_40 AC 2 ms
4,348 KB
testcase_41 AC 2 ms
4,348 KB
testcase_42 RE -
testcase_43 AC 2 ms
4,348 KB
testcase_44 AC 2 ms
4,348 KB
testcase_45 AC 2 ms
4,348 KB
testcase_46 RE -
testcase_47 AC 2 ms
4,348 KB
testcase_48 RE -
testcase_49 AC 1 ms
4,348 KB
testcase_50 AC 2 ms
4,348 KB
testcase_51 AC 2 ms
4,348 KB
testcase_52 AC 2 ms
4,348 KB
testcase_53 AC 2 ms
4,348 KB
testcase_54 AC 1 ms
4,348 KB
testcase_55 AC 2 ms
4,348 KB
testcase_56 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <math.h>
#include <atcoder/modint.hpp>

using namespace std;
using namespace atcoder;
using ll = long long;
using mint = modint998244353;

int main() {
  ll n, m;
  cin >> n >> m;
  mint ans = 0;
  vector<mint> f(n + 1, 1);
  for (ll i = 0; i < n; i++)
    f[i + 1] = f[i] * (i + 1);
  for (ll y = 0; y < n; y++) {
    ll x2 = y * y + m;
    ll x = sqrt(x2) - 2;
    while (x * x - y * y < m)
      x++;
    if (x * x - y * y != m)
      continue;
    if ((n - x - y) % 2)
      continue;
    ll pm = (n - x - y) / 2;
    for (ll pmx = 0; pmx <= pm; pmx++) {
      ll pmy = pm - pmx;
      vector<ll> c = { x + pmx,pmx,y + pmy,pmy };
      ll nc = n;
      mint tmp = 1;
      for (ll i = 0; i < 4; i++) {
        tmp *= f[nc] / (f[c[i]] * f[nc - c[i]]);
        nc -= c[i];
      }
      if (y)
        ans += tmp * 4;
      else
        ans += tmp * 2;
    }
  }
  ans /= mint(4).pow(n);
  cout << ans.val() << "\n";
  return 0;
}
0