結果

問題 No.2406 Difference of Coordinate Squared
ユーザー ぷらぷら
提出日時 2023-08-05 07:55:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,201 bytes
コンパイル時間 1,512 ms
コンパイル使用メモリ 139,864 KB
実行使用メモリ 50,636 KB
最終ジャッジ日時 2024-04-23 05:44:55
合計ジャッジ時間 6,087 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
50,176 KB
testcase_01 AC 61 ms
50,480 KB
testcase_02 AC 73 ms
50,548 KB
testcase_03 WA -
testcase_04 AC 68 ms
50,328 KB
testcase_05 AC 61 ms
50,580 KB
testcase_06 AC 60 ms
50,308 KB
testcase_07 AC 54 ms
50,320 KB
testcase_08 AC 65 ms
50,304 KB
testcase_09 AC 52 ms
50,444 KB
testcase_10 AC 62 ms
50,304 KB
testcase_11 AC 63 ms
50,492 KB
testcase_12 AC 74 ms
50,560 KB
testcase_13 AC 55 ms
50,508 KB
testcase_14 AC 64 ms
50,432 KB
testcase_15 AC 55 ms
50,332 KB
testcase_16 AC 67 ms
50,276 KB
testcase_17 AC 53 ms
50,352 KB
testcase_18 WA -
testcase_19 AC 61 ms
50,508 KB
testcase_20 AC 64 ms
50,304 KB
testcase_21 AC 55 ms
50,348 KB
testcase_22 WA -
testcase_23 AC 51 ms
50,504 KB
testcase_24 AC 64 ms
50,216 KB
testcase_25 WA -
testcase_26 AC 62 ms
50,300 KB
testcase_27 WA -
testcase_28 AC 64 ms
50,164 KB
testcase_29 AC 53 ms
50,192 KB
testcase_30 AC 58 ms
50,176 KB
testcase_31 AC 54 ms
50,360 KB
testcase_32 AC 64 ms
50,176 KB
testcase_33 AC 52 ms
50,452 KB
testcase_34 AC 61 ms
50,304 KB
testcase_35 AC 51 ms
50,608 KB
testcase_36 AC 63 ms
50,560 KB
testcase_37 AC 50 ms
50,320 KB
testcase_38 AC 63 ms
50,432 KB
testcase_39 WA -
testcase_40 AC 62 ms
50,432 KB
testcase_41 AC 55 ms
50,416 KB
testcase_42 WA -
testcase_43 AC 52 ms
50,444 KB
testcase_44 AC 54 ms
50,300 KB
testcase_45 AC 57 ms
50,184 KB
testcase_46 AC 62 ms
50,304 KB
testcase_47 AC 55 ms
50,180 KB
testcase_48 WA -
testcase_49 AC 54 ms
50,392 KB
testcase_50 AC 63 ms
50,304 KB
testcase_51 AC 50 ms
50,372 KB
testcase_52 AC 60 ms
50,432 KB
testcase_53 AC 50 ms
50,328 KB
testcase_54 AC 63 ms
50,548 KB
testcase_55 AC 55 ms
50,540 KB
testcase_56 AC 60 ms
50,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <string.h>
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;

constexpr int mod = 998244353;

long long fac[2000005], finv[2000005], inv[2000005];

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

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

long long choose(int n,int k) {
    if(n < 0 || k < 0) return 0;
    if(n == 0) return 1;
    return COM(n+k-1,k-1);
}

long long modpow(long long a,long long b) {
    long long ans = 1;
    while(b) {
        if(b & 1) {
            (ans *= a) %= mod;
        }
        (a *= a) %= mod;
        b /= 2;
    }
    return ans;
}

void mpl(int &x,int y) {
    x += y;
    if(x >= mod) x -= mod;
}

int main() {
    COMinit();
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    long long M;
    cin >> N >> M;
    long long m = abs(M);
    vector<long long>tmp;
    for(long long i = 1; i*i <= m; i++) {
        if(m%i == 0) {
            tmp.push_back(i);
            if(i*i != m) tmp.push_back(M/i);
        }
    }
    int sum = 0;
    for(int i = 0; i < tmp.size(); i++) {
        long long a = tmp[i],b = M/tmp[i];
        if(abs(a)%2 != N%2 || a > N || a < -N) continue;
        if(abs(b)%2 != N%2 || b > N || b < -N) continue;
        long long p1 = (a+N)/2,p2 = (N-a)/2;
        long long p3 = (b+N)/2,p4 = (N-b)/2;
        mpl(sum,COM(N,p1)*COM(N,p3)%mod);
    }
    mpl(sum,sum);
    cout << sum*modpow(modpow(4,N),mod-2)%mod << "\n";
}
0