結果
| 問題 |
No.2406 Difference of Coordinate Squared
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-07-12 01:25:38 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 998 bytes |
| コンパイル時間 | 1,669 ms |
| コンパイル使用メモリ | 173,808 KB |
| 実行使用メモリ | 11,020 KB |
| 最終ジャッジ日時 | 2024-09-18 20:13:08 |
| 合計ジャッジ時間 | 5,630 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 1 |
| other | AC * 46 WA * 9 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/modint>
using namespace atcoder;
using mint=modint998244353;
int main(void)
{
long long n,m;
cin >> n >> m;
vector<mint> fact(n+1,1);
vector<mint> fact_inv(n+1,1);
for(int i=1;i<=n;++i){
fact[i]=fact[i-1]*i;
fact_inv[i]=fact_inv[i-1]/i;
}
mint ans=0;
for(long long y=0;y<=n;++y){
long long x=sqrt(y*y+m);
if(x*x-y*y!=m){
continue;
}
if(x+y>n){
continue;
}
if((n-x-y)%2){
continue;
}
long long a=x+(n-x-y)/2;
long long b=(n-x-y)/2;
if(a>n){
continue;
}
if(y){
ans+=4*fact[n]*fact_inv[a]*fact_inv[n-a]*fact[n]*fact_inv[b]*fact_inv[n-b];
} else {
ans+=2*fact[n]*fact_inv[a]*fact_inv[n-a]*fact[n]*fact_inv[b]*fact_inv[n-b];
}
}
ans/=mint(4).pow(n);
cout << ans.val() << endl;
return 0;
}