結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 63 ms
50,516 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 71 ms
50,304 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 63 ms
50,172 KB
testcase_12 AC 73 ms
50,304 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 63 ms
50,468 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 64 ms
50,304 KB
testcase_29 WA -
testcase_30 AC 65 ms
50,460 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 64 ms
50,440 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 56 ms
50,460 KB
testcase_42 WA -
testcase_43 AC 54 ms
50,424 KB
testcase_44 AC 68 ms
50,332 KB
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 AC 64 ms
50,424 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 AC 54 ms
50,436 KB
testcase_56 AC 65 ms
50,296 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;
    if(M == 0) {
        if(N%2 == 0) {
            cout << COM(N,N/2)*modpow(2,N)%mod*modpow(modpow(4,N),mod-2)%mod << "\n";
        }
        else {
            cout << 0 << "\n";
        }
        return 0;
    }
    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);
    }
    cout << sum*modpow(modpow(4,N),mod-2)%mod << "\n";
}
0