結果

問題 No.2406 Difference of Coordinate Squared
ユーザー 👑 amentorimaruamentorimaru
提出日時 2023-07-01 04:14:25
言語 C++17(clang)
(17.0.6 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 803 bytes
コンパイル時間 1,238 ms
コンパイル使用メモリ 131,328 KB
実行使用メモリ 7,200 KB
最終ジャッジ日時 2024-09-18 20:12:19
合計ジャッジ時間 3,607 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 1
other AC * 21 WA * 34
権限があれば一括ダウンロードができます

ソースコード

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 a = abs(n - x + y) / 2;
    ll b = abs(n - x - y) / 2;
    mint tmp = f[n] * f[n] / (f[a] * f[n - a] * f[b] * f[n - b]);
    if (y)
      tmp *= 4;
    else
      tmp *= 2;
    ans += tmp;
  }
  ans /= mint(4).pow(n);
  cout << ans.val() << "\n";
  return 0;
}
0