結果

問題 No.2406 Difference of Coordinate Squared
ユーザー flygonflygon
提出日時 2023-08-04 22:49:44
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,262 bytes
コンパイル時間 284 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 337,544 KB
最終ジャッジ日時 2024-04-22 21:09:42
合計ジャッジ時間 5,811 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
60,288 KB
testcase_01 AC 851 ms
251,008 KB
testcase_02 AC 926 ms
251,136 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(5*10**5)
input = sys.stdin.readline
from collections import defaultdict, deque, Counter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right
from math import gcd

n,m = map(int,input().split())
s = set()
for i in range(n+1):
    s.add(i**2)
xy = []
for i in range(n+1):
    xx = i*i
    yy = xx-m
    if yy in s:
        xy.append([i, int(pow(yy,0.5))])
mod = 998244353

# nCk
def com(n, mod):
    fact = [1, 1]
    factinv = [1, 1]
    inv = [0, 1]
    for i in range(2, n+1):
        fact.append((fact[-1]*i) % mod)
        inv.append((-inv[mod % i]*(mod//i)) % mod)
        factinv.append((factinv[-1]*inv[-1]) % mod)
    return fact, factinv
f,fi = com(n+10, mod)

ans = 0
for x,y in xy:
    for dx in range(n+1):
        dy = n-dx
        if dx < x or dy < y: continue
        if dx%2 != x%2 or dy%2 != y%2: continue
        a = x + (dx-x)//2
        b = (dx-x)//2
        c = y + (dy-y)//2
        d = (dy-y)//2

        tmp = f[n] * fi[a]%mod * fi[b]%mod * fi[c]%mod * fi[d] %mod
        if x != 0:
            tmp *= 2
            tmp %= mod
        if y != 0:
            tmp *= 2
            tmp %= mod
        ans += tmp
        ans %= mod
print(ans * pow(pow(4, n, mod), mod-2, mod) % mod)
0