結果

問題 No.2406 Difference of Coordinate Squared
ユーザー momoyuumomoyuu
提出日時 2023-10-23 13:10:44
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,654 bytes
コンパイル時間 1,493 ms
コンパイル使用メモリ 120,860 KB
実行使用メモリ 85,104 KB
最終ジャッジ日時 2023-10-23 13:11:05
合計ジャッジ時間 20,186 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 276 ms
19,264 KB
testcase_01 WA -
testcase_02 AC 288 ms
19,396 KB
testcase_03 AC 719 ms
85,104 KB
testcase_04 AC 286 ms
19,396 KB
testcase_05 AC 287 ms
19,396 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 282 ms
19,268 KB
testcase_09 AC 281 ms
19,328 KB
testcase_10 AC 280 ms
19,272 KB
testcase_11 AC 287 ms
19,268 KB
testcase_12 AC 276 ms
19,264 KB
testcase_13 WA -
testcase_14 AC 281 ms
19,268 KB
testcase_15 AC 282 ms
19,268 KB
testcase_16 WA -
testcase_17 AC 278 ms
19,272 KB
testcase_18 AC 330 ms
27,532 KB
testcase_19 AC 286 ms
19,268 KB
testcase_20 WA -
testcase_21 AC 282 ms
19,268 KB
testcase_22 AC 414 ms
52,104 KB
testcase_23 WA -
testcase_24 AC 298 ms
19,272 KB
testcase_25 AC 286 ms
20,956 KB
testcase_26 WA -
testcase_27 AC 277 ms
19,320 KB
testcase_28 AC 277 ms
19,264 KB
testcase_29 AC 277 ms
19,268 KB
testcase_30 AC 277 ms
19,264 KB
testcase_31 AC 277 ms
19,268 KB
testcase_32 AC 276 ms
19,268 KB
testcase_33 WA -
testcase_34 AC 277 ms
19,268 KB
testcase_35 WA -
testcase_36 AC 277 ms
19,268 KB
testcase_37 AC 277 ms
19,268 KB
testcase_38 AC 276 ms
19,264 KB
testcase_39 AC 277 ms
19,296 KB
testcase_40 WA -
testcase_41 AC 277 ms
19,264 KB
testcase_42 AC 278 ms
19,392 KB
testcase_43 AC 277 ms
19,268 KB
testcase_44 AC 276 ms
19,264 KB
testcase_45 AC 278 ms
19,268 KB
testcase_46 WA -
testcase_47 AC 277 ms
19,272 KB
testcase_48 AC 277 ms
19,328 KB
testcase_49 AC 303 ms
19,268 KB
testcase_50 AC 305 ms
19,268 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 AC 276 ms
19,268 KB
testcase_56 AC 279 ms
19,296 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<stack>
#include<vector>
#include<set>

using namespace std;
using ll = long long;

#include<atcoder/modint>
using mint = atcoder::modint998244353;


const int mx = 2e6 + 10;
mint fac[mx],ifac[mx];
mint comb(int n,int r){
    return fac[n] * ifac[r] * ifac[n-r];
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    ll n,m;
    cin>>n>>m;
    fac[0] = 1;
    for(int i = 1;i<mx;i++) fac[i] = fac[i-1] * i;
    for(int i = 0;i<mx;i++) ifac[i] = fac[i].inv();

    mint ans = 0;
    vector<pair<ll,ll>> use;
    if(m==0){
        for(int i = 1;i<=n;i++) {
            use.push_back(make_pair(0,i));
            use.push_back(make_pair(0,-i));
            use.push_back(make_pair(i,0));
            use.push_back(make_pair(-i,0));
        }
        use.push_back(make_pair(0,0));
    }
    for(ll i = 1;i*i<=m;i++){
        if(m%i!=0) continue;
        ll a = i;
        ll b = m / i;
        use.push_back(make_pair(a,b));
        use.push_back(make_pair(-a,-b));
        swap(a,b);
        use.push_back(make_pair(a,b));
        use.push_back(make_pair(-a,-b));
    }
    sort(use.begin(),use.end());
    use.erase(unique(use.begin(),use.end()),use.end());
    for(int i = 0;i<use.size();i++){
        auto now = use[i];
        ll a = now.first;
        ll b = now.second;
        a = abs(a);
        b = abs(b);
        ll all = n;
        if(n%2!=a%2) continue;
        if(n%2!=b%2) continue;
        ll x = (a+n) / 2;
        ll y = (b+n) / 2;
        if(x>n||y>n) continue;
        ans += comb(n,x) * comb(n,y);
    }
    ans /= mint(4).pow(n);
    cout<<ans.val()<<endl;
    
}


0