結果

問題 No.2406 Difference of Coordinate Squared
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2023-11-29 13:30:28
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,738 bytes
コンパイル時間 379 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 250,688 KB
最終ジャッジ日時 2023-11-29 13:30:39
合計ジャッジ時間 9,455 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
55,736 KB
testcase_01 AC 293 ms
250,688 KB
testcase_02 AC 301 ms
250,688 KB
testcase_03 WA -
testcase_04 AC 318 ms
250,688 KB
testcase_05 AC 64 ms
64,320 KB
testcase_06 AC 161 ms
165,336 KB
testcase_07 AC 145 ms
143,928 KB
testcase_08 AC 207 ms
209,256 KB
testcase_09 AC 217 ms
228,556 KB
testcase_10 AC 285 ms
250,688 KB
testcase_11 AC 234 ms
228,224 KB
testcase_12 AC 249 ms
248,384 KB
testcase_13 AC 238 ms
249,664 KB
testcase_14 AC 248 ms
249,024 KB
testcase_15 AC 297 ms
250,688 KB
testcase_16 AC 189 ms
193,272 KB
testcase_17 AC 46 ms
55,736 KB
testcase_18 WA -
testcase_19 AC 262 ms
249,024 KB
testcase_20 AC 264 ms
250,688 KB
testcase_21 AC 193 ms
178,744 KB
testcase_22 WA -
testcase_23 AC 270 ms
250,688 KB
testcase_24 AC 110 ms
113,620 KB
testcase_25 WA -
testcase_26 AC 45 ms
55,736 KB
testcase_27 WA -
testcase_28 AC 44 ms
57,840 KB
testcase_29 AC 44 ms
55,736 KB
testcase_30 AC 45 ms
57,840 KB
testcase_31 AC 45 ms
57,840 KB
testcase_32 AC 45 ms
55,736 KB
testcase_33 AC 58 ms
55,736 KB
testcase_34 AC 45 ms
57,840 KB
testcase_35 AC 46 ms
57,840 KB
testcase_36 AC 44 ms
55,736 KB
testcase_37 AC 45 ms
57,840 KB
testcase_38 AC 46 ms
57,840 KB
testcase_39 WA -
testcase_40 AC 45 ms
55,736 KB
testcase_41 AC 45 ms
55,736 KB
testcase_42 WA -
testcase_43 AC 46 ms
57,840 KB
testcase_44 AC 45 ms
57,840 KB
testcase_45 AC 44 ms
55,736 KB
testcase_46 AC 42 ms
55,736 KB
testcase_47 AC 43 ms
57,840 KB
testcase_48 WA -
testcase_49 AC 44 ms
55,736 KB
testcase_50 AC 44 ms
55,736 KB
testcase_51 AC 45 ms
57,840 KB
testcase_52 AC 44 ms
55,736 KB
testcase_53 AC 46 ms
55,736 KB
testcase_54 AC 45 ms
57,840 KB
testcase_55 AC 44 ms
55,736 KB
testcase_56 AC 45 ms
55,736 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *
from itertools import *
from functools import *
from heapq import *
import sys,math
input = sys.stdin.readline
mod = 998244353

class combination():
    
    def __init__(self,N,p):
        
        
        self.fact = [1, 1]  # fact[n] = (n! mod p)
        self.factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
        self.inv = [0, 1]  # factinv 計算用
        self.p = p
        self.N = N
        
        
        for i in range(2, N + 1):
            self.fact.append((self.fact[-1] * i) % p)
            self.inv.append((-self.inv[p % i] * (p // i)) % p)
            self.factinv.append((self.factinv[-1] * self.inv[-1]) % p)
        

    def cmb(self,n, r):
        if (r < 0) or (n < r):
            return 0
            
        if self.N < n:
            
            r = min(n-r,r)
            
            tmp = factinv[r]
            for j in range(r):
                tmp = tmp*(n-j)%sefl.p
            return tmp
                
            
        r = min(r, n - r)
        return self.fact[n] * self.factinv[r] * self.factinv[n-r] % self.p
        

N,M = map(int,input().split())

M = abs(M)

def md(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
    
C = combination(N+1,mod)

ans = 0
for p in md(M):
    
    u,v = p,M//p
    
    if ((N-u)%2==1)|((N-v)%2==1):
        continue
    if u>N:
        continue
    if v>N:
        continue
    
    du = (N-u)//2
    dv = (N-v)//2
    ans += C.cmb(N,du)*C.cmb(N,dv)*2%mod
print(ans*pow(4,N*(mod-2),mod)%mod)
0