結果

問題 No.2406 Difference of Coordinate Squared
ユーザー otoshigootoshigo
提出日時 2023-08-04 23:04:33
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,803 bytes
コンパイル時間 939 ms
コンパイル使用メモリ 83,476 KB
実行使用メモリ 26,752 KB
最終ジャッジ日時 2024-04-22 21:28:42
合計ジャッジ時間 7,601 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
26,624 KB
testcase_01 AC 95 ms
26,588 KB
testcase_02 AC 89 ms
26,496 KB
testcase_03 WA -
testcase_04 AC 136 ms
26,624 KB
testcase_05 AC 74 ms
26,752 KB
testcase_06 AC 77 ms
26,496 KB
testcase_07 AC 66 ms
26,624 KB
testcase_08 AC 70 ms
26,496 KB
testcase_09 AC 187 ms
26,496 KB
testcase_10 AC 88 ms
26,696 KB
testcase_11 AC 78 ms
26,496 KB
testcase_12 AC 79 ms
26,624 KB
testcase_13 AC 211 ms
26,624 KB
testcase_14 AC 102 ms
26,624 KB
testcase_15 AC 76 ms
26,624 KB
testcase_16 AC 103 ms
26,624 KB
testcase_17 AC 71 ms
26,752 KB
testcase_18 WA -
testcase_19 AC 77 ms
26,700 KB
testcase_20 AC 140 ms
26,624 KB
testcase_21 AC 66 ms
26,664 KB
testcase_22 WA -
testcase_23 AC 145 ms
26,624 KB
testcase_24 AC 89 ms
26,740 KB
testcase_25 WA -
testcase_26 AC 81 ms
26,524 KB
testcase_27 WA -
testcase_28 AC 82 ms
26,528 KB
testcase_29 AC 95 ms
26,528 KB
testcase_30 AC 74 ms
26,624 KB
testcase_31 AC 99 ms
26,496 KB
testcase_32 AC 68 ms
26,624 KB
testcase_33 AC 73 ms
26,624 KB
testcase_34 AC 76 ms
26,624 KB
testcase_35 AC 84 ms
26,660 KB
testcase_36 AC 73 ms
26,592 KB
testcase_37 AC 65 ms
26,624 KB
testcase_38 AC 86 ms
26,624 KB
testcase_39 WA -
testcase_40 AC 84 ms
26,740 KB
testcase_41 AC 85 ms
26,748 KB
testcase_42 WA -
testcase_43 AC 74 ms
26,496 KB
testcase_44 AC 75 ms
26,620 KB
testcase_45 AC 86 ms
26,752 KB
testcase_46 AC 71 ms
26,624 KB
testcase_47 AC 78 ms
26,624 KB
testcase_48 WA -
testcase_49 AC 82 ms
26,624 KB
testcase_50 AC 91 ms
26,700 KB
testcase_51 AC 88 ms
26,624 KB
testcase_52 AC 83 ms
26,752 KB
testcase_53 AC 96 ms
26,624 KB
testcase_54 AC 64 ms
26,624 KB
testcase_55 AC 87 ms
26,624 KB
testcase_56 AC 81 ms
26,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
#include<atcoder/modint>
using namespace std;
using ll=long long;
using mint=atcoder::modint998244353;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
template<class T> bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;}
template<class T> bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;}

const ll MOD=998244353;
const int MAX=2e6+10;
vector<mint>fac(MAX),finv(MAX),inv(MAX);

void set_fac(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for (int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i;
        inv[i]=-inv[MOD%i]*(MOD/i);
        finv[i]=finv[i-1]*inv[i];
    }
}

mint cmb(int n,int r){
    if (r<0||n<r)return 0;
    return fac[n]*finv[r]*finv[n-r];
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    set_fac();
    ll N,M;
    cin>>N>>M;
    M=abs(M);
    ll p=1;
    mint ans=0,P4=mint(4).pow(N);
    while(p*p<=M){
        if(M%p==0){
            int q=M/p;
            if((p+q)%2==0){
                ll x=abs((p+q)/2),y=abs((p-q)/2);
                if((x+y)%2==N%2){
                    for(int i=x;i<=N;i+=2){
                        int b=(i-x)/2,a=x+b;
                        int j=N-i;
                        int d=(j-y)/2,c=y+d;
                        if(d>=0){
                            mint r=fac[N]*finv[a]*finv[b]*finv[c]*finv[d];
                            if(x==0&&y==0)ans+=r;
                            else if(x==0||y==0)ans+=2*r;
                            else ans+=4*r;
                        }
                    }
                }
            }
        }
        p++;
    }
    ans/=P4;
    cout<<ans.val()<<"\n";
}
0