結果

問題 No.2406 Difference of Coordinate Squared
ユーザー GoldIngotGoldIngot
提出日時 2023-08-04 22:49:52
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,320 bytes
コンパイル時間 4,027 ms
コンパイル使用メモリ 256,472 KB
実行使用メモリ 15,096 KB
最終ジャッジ日時 2024-04-22 21:09:48
合計ジャッジ時間 5,647 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 25 ms
14,952 KB
testcase_02 WA -
testcase_03 AC 15 ms
15,032 KB
testcase_04 WA -
testcase_05 AC 9 ms
6,940 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 15 ms
11,096 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 21 ms
12,296 KB
testcase_12 AC 22 ms
13,068 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 4 ms
6,940 KB
testcase_19 AC 23 ms
13,640 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 6 ms
7,040 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 2 ms
6,940 KB
testcase_26 WA -
testcase_27 AC 2 ms
6,940 KB
testcase_28 AC 1 ms
6,940 KB
testcase_29 WA -
testcase_30 AC 1 ms
6,940 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 2 ms
6,944 KB
testcase_39 AC 1 ms
6,948 KB
testcase_40 WA -
testcase_41 AC 2 ms
6,944 KB
testcase_42 AC 2 ms
6,940 KB
testcase_43 AC 1 ms
6,944 KB
testcase_44 AC 2 ms
6,944 KB
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 AC 2 ms
6,940 KB
testcase_49 WA -
testcase_50 AC 1 ms
6,944 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define rep2ll(i,m,n) for(ll (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF60 = 1LL<<60;//1152921504606846976
const int INF30 = 1<<30;
using mint = modint998244353;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
using VM = vector<mint>;
using VVM = vector<VM>;
using VVVM = vector<VVM>;
using VD = vector<double>;
using VVD = vector<VD>;
using VVVD = vector<VVD>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template< typename T >
struct Combination {
  vector< T > _fact, _rfact, _inv;

  Combination(int sz) : _fact(sz + 1), _rfact(sz + 1), _inv(sz + 1) {
    _fact[0] = _rfact[sz] = _inv[0] = 1;
    for(int i = 1; i <= sz; i++) _fact[i] = _fact[i - 1] * i;
    _rfact[sz] /= _fact[sz];
    for(int i = sz - 1; i >= 0; i--) _rfact[i] = _rfact[i + 1] * (i + 1);
    for(int i = 1; i <= sz; i++) _inv[i] = _rfact[i] * _fact[i - 1];
  }

  inline T fact(int k) const { return _fact[k]; }

  inline T rfact(int k) const { return _rfact[k]; }

  inline T inv(int k) const { return _inv[k]; }

  T P(int n, int r) const {
    if(r < 0 || n < r) return 0;
    return fact(n) * rfact(n - r);
  }

  T C(int p, int q) const {
    if(q < 0 || p < q) return 0;
    return fact(p) * rfact(q) * rfact(p - q);
  }

  T H(int n, int r) const {
    if(n < 0 || r < 0) return (0);
    return r == 0 ? 1 : C(n + r - 1, r);
  }
};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, m; cin>>n>>m;
    m = abs(m);
    Combination<mint> c(n);
    mint ans = 0;
    if(m==0){
        if(n%2) ans = 0;
        else ans = c.C(n,n/2)*mint(2).pow(n+1)-c.C(n,n/2).pow(2);
    }else{
        for(ll x=1; x*x<=m; x++){
            if(m%x) continue;
            ll y = m/x;
            ans += c.C(n, x) * c.C(n, y) * (1+(x!=y));
        }
        ans *= 2;
    }
    // cerr<<ans.val()<<endl;
    cout<<(ans/mint(4).pow(n)).val();
    
    return 0;
}
0