結果
問題 | No.986 Present |
ユーザー | maspy |
提出日時 | 2020-02-13 00:03:03 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 490 ms / 2,000 ms |
コード長 | 1,374 bytes |
コンパイル時間 | 190 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 54,104 KB |
最終ジャッジ日時 | 2024-10-04 07:51:06 |
合計ジャッジ時間 | 17,954 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 435 ms
44,428 KB |
testcase_01 | AC | 439 ms
43,784 KB |
testcase_02 | AC | 445 ms
44,300 KB |
testcase_03 | AC | 469 ms
49,608 KB |
testcase_04 | AC | 445 ms
44,168 KB |
testcase_05 | AC | 460 ms
47,944 KB |
testcase_06 | AC | 455 ms
47,500 KB |
testcase_07 | AC | 453 ms
44,676 KB |
testcase_08 | AC | 446 ms
44,656 KB |
testcase_09 | AC | 476 ms
51,928 KB |
testcase_10 | AC | 440 ms
44,424 KB |
testcase_11 | AC | 469 ms
49,096 KB |
testcase_12 | AC | 460 ms
45,912 KB |
testcase_13 | AC | 445 ms
44,684 KB |
testcase_14 | AC | 445 ms
44,172 KB |
testcase_15 | AC | 490 ms
54,076 KB |
testcase_16 | AC | 457 ms
47,368 KB |
testcase_17 | AC | 478 ms
49,732 KB |
testcase_18 | AC | 471 ms
50,768 KB |
testcase_19 | AC | 470 ms
52,240 KB |
testcase_20 | AC | 442 ms
44,424 KB |
testcase_21 | AC | 475 ms
53,452 KB |
testcase_22 | AC | 474 ms
54,104 KB |
testcase_23 | AC | 482 ms
45,832 KB |
testcase_24 | AC | 486 ms
53,580 KB |
testcase_25 | AC | 448 ms
44,292 KB |
testcase_26 | AC | 477 ms
53,084 KB |
testcase_27 | AC | 469 ms
48,460 KB |
testcase_28 | AC | 474 ms
53,704 KB |
testcase_29 | AC | 467 ms
52,448 KB |
testcase_30 | AC | 455 ms
44,172 KB |
testcase_31 | AC | 465 ms
51,664 KB |
testcase_32 | AC | 478 ms
52,300 KB |
ソースコード
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import numpy as np N, M = map(int, read().split()) MOD = 998244353 def cumprod(A, MOD = MOD): L = len(A); Lsq = int(L**.5+1) A = np.resize(A, Lsq**2).reshape(Lsq,Lsq) for n in range(1,Lsq): A[:,n] *= A[:,n-1]; A[:,n] %= MOD for n in range(1,Lsq): A[n] *= A[n-1,-1]; A[n] %= MOD return A.ravel()[:L] def make_fact(U, MOD = MOD): x = np.arange(U, dtype = np.int64); x[0] = 1 fact = cumprod(x, MOD) x = np.arange(U, 0, -1, dtype=np.int64); x[0] = pow(int(fact[-1]), MOD-2, MOD) fact_inv = cumprod(x, MOD)[::-1] fact.flags.writeable = False fact_inv.flags.writeable = False return fact,fact_inv def make_power(a, L, MOD=MOD): B = L.bit_length() x = np.empty((1<<B), np.int64) x[0] = 1 for n in range(B): x[1<<n:1<<(n+1)] = x[:1<<n] * a % MOD a *= a; a %= MOD x = x[:L] x.flags.writeable = False return x pow_2 = make_power(2, M + 10, MOD) answer = [0,0,0] answer[0] = pow_2[N] x = pow_2[M] - pow_2[:N] answer[1] = cumprod(x)[-1] x = pow_2[N] - pow_2[:N] answer[2] = answer[1] * pow(int(cumprod(x)[-1]), MOD-2, MOD) % MOD # 順序対じゃないよ! _, fact_inv = make_fact(M + 10) answer[1] *= fact_inv[N] answer[1] %= MOD print(*answer)