結果

問題 No.2406 Difference of Coordinate Squared
ユーザー 👑 獅子座じゃない人獅子座じゃない人
提出日時 2023-07-12 01:33:26
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,012 bytes
コンパイル時間 1,678 ms
コンパイル使用メモリ 172,884 KB
実行使用メモリ 11,092 KB
最終ジャッジ日時 2023-10-19 00:14:50
合計ジャッジ時間 5,421 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 148 ms
11,084 KB
testcase_02 AC 148 ms
11,084 KB
testcase_03 WA -
testcase_04 AC 147 ms
11,084 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 69 ms
6,732 KB
testcase_07 AC 56 ms
6,204 KB
testcase_08 AC 100 ms
8,580 KB
testcase_09 AC 105 ms
8,844 KB
testcase_10 AC 138 ms
10,624 KB
testcase_11 AC 115 ms
9,304 KB
testcase_12 AC 127 ms
9,836 KB
testcase_13 AC 121 ms
9,568 KB
testcase_14 AC 130 ms
10,100 KB
testcase_15 AC 144 ms
10,820 KB
testcase_16 AC 90 ms
8,052 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 WA -
testcase_19 AC 131 ms
10,100 KB
testcase_20 AC 139 ms
10,624 KB
testcase_21 AC 81 ms
7,524 KB
testcase_22 WA -
testcase_23 AC 145 ms
11,084 KB
testcase_24 AC 36 ms
5,148 KB
testcase_25 WA -
testcase_26 AC 2 ms
4,348 KB
testcase_27 WA -
testcase_28 AC 2 ms
4,348 KB
testcase_29 AC 2 ms
4,348 KB
testcase_30 AC 2 ms
4,348 KB
testcase_31 AC 2 ms
4,348 KB
testcase_32 AC 2 ms
4,348 KB
testcase_33 AC 2 ms
4,348 KB
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 2 ms
4,348 KB
testcase_38 AC 2 ms
4,348 KB
testcase_39 WA -
testcase_40 AC 2 ms
4,348 KB
testcase_41 AC 2 ms
4,348 KB
testcase_42 WA -
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 AC 2 ms
4,348 KB
testcase_47 AC 2 ms
4,348 KB
testcase_48 WA -
testcase_49 AC 2 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 1 ms
4,348 KB
testcase_54 AC 2 ms
4,348 KB
testcase_55 AC 2 ms
4,348 KB
testcase_56 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
    m=abs(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;
}
0