結果
問題 | No.2406 Difference of Coordinate Squared |
ユーザー |
👑 ![]() |
提出日時 | 2023-06-30 13:22:04 |
言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 979 bytes |
コンパイル時間 | 2,900 ms |
コンパイル使用メモリ | 129,536 KB |
実行使用メモリ | 7,324 KB |
最終ジャッジ日時 | 2024-09-18 20:13:27 |
合計ジャッジ時間 | 13,313 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 1 |
other | AC * 43 WA * 1 RE * 9 TLE * 2 |
ソースコード
#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; }