結果
問題 | No.2045 Two Reflections |
ユーザー | shotoyoo |
提出日時 | 2022-08-20 20:47:08 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 139 ms / 2,000 ms |
コード長 | 2,493 bytes |
コンパイル時間 | 303 ms |
コンパイル使用メモリ | 82,416 KB |
実行使用メモリ | 87,152 KB |
最終ジャッジ日時 | 2024-10-09 12:34:51 |
合計ジャッジ時間 | 3,719 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 45 ms
57,164 KB |
testcase_01 | AC | 46 ms
56,184 KB |
testcase_02 | AC | 98 ms
87,044 KB |
testcase_03 | AC | 139 ms
87,152 KB |
testcase_04 | AC | 127 ms
86,536 KB |
testcase_05 | AC | 59 ms
67,648 KB |
testcase_06 | AC | 59 ms
70,188 KB |
testcase_07 | AC | 130 ms
86,996 KB |
testcase_08 | AC | 113 ms
86,456 KB |
testcase_09 | AC | 74 ms
80,868 KB |
testcase_10 | AC | 61 ms
75,216 KB |
testcase_11 | AC | 95 ms
79,448 KB |
testcase_12 | AC | 45 ms
56,284 KB |
testcase_13 | AC | 45 ms
57,020 KB |
testcase_14 | AC | 45 ms
56,344 KB |
testcase_15 | AC | 45 ms
56,856 KB |
testcase_16 | AC | 44 ms
56,888 KB |
testcase_17 | AC | 77 ms
81,436 KB |
testcase_18 | AC | 76 ms
81,484 KB |
testcase_19 | AC | 76 ms
81,264 KB |
testcase_20 | AC | 78 ms
81,364 KB |
testcase_21 | AC | 106 ms
87,100 KB |
testcase_22 | AC | 109 ms
87,084 KB |
testcase_23 | AC | 109 ms
87,152 KB |
testcase_24 | AC | 103 ms
86,984 KB |
testcase_25 | AC | 100 ms
86,944 KB |
testcase_26 | AC | 101 ms
86,932 KB |
testcase_27 | AC | 103 ms
87,108 KB |
testcase_28 | AC | 104 ms
87,072 KB |
testcase_29 | AC | 101 ms
86,836 KB |
ソースコード
import sys, random input = lambda : sys.stdin.readline().rstrip() write = lambda x: sys.stdout.write(x+"\n"); writef = lambda x: print("{:.12f}".format(x)) debug = lambda x: sys.stderr.write(x+"\n") YES="Yes"; NO="No"; pans = lambda v: print(YES if v else NO); INF=10**18 LI = lambda : list(map(int, input().split())); II=lambda : int(input()) def debug(_l_): for s in _l_.split(): print(f"{s}={eval(s)}", end=" ") print() def dlist(*l, fill=0): if len(l)==1: return [fill]*l[0] ll = l[1:] return [dlist(*ll, fill=fill) for _ in range(l[0])] def hurui(n): """線形篩 pl: 素数のリスト mpf: iを割り切る最小の素因数 """ pl = [] mpf = [None]*(n+1) for d in range(2,n+1): if mpf[d] is None: mpf[d] = d pl.append(d) for p in pl: if p*d>n or p>mpf[d]: break mpf[p*d] = p return pl, mpf from collections import defaultdict def factor(num): d = defaultdict(int) if num==1: d.update({1:1}) return d while num>1: d[mpf[num]] += 1 num //= mpf[num] return d def fs(num): f = factor(num) ans = [1] for k,v in f.items(): tmp = [] for i in range(len(ans)): val = 1 for _ in range(v): val *= k ans.append(ans[i]*val) return ans n,p,q = list(map(int, input().split())) pl, mpf = hurui(2*n+10) M = 998244353 if n==1: ans = 1 elif p+q<=n: ans = 1 if p>1: ans *= 2 if q>1: ans *= 2 elif p==q==n: ans = 2 elif p==1 or q==1: ans = 2 else: dp = [[-1]*n for _ in range(2)] np = list(range(n)) nq = list(range(n)) for i in range(p): np[i] = p-1-i for i in range(n-q,n): nq[i] = n-1-(i - (n-q)) nx = [np, nq] cs = [] kv = {} for i in range(2): for j in range(n): if dp[i][j]!=-1: continue c = 1 dp[i][j] = (i,j) ii = 1-i jj = nx[i][j] while ii!=i or jj!=j: dp[ii][jj] = (i,j) c += 1 jj = nx[ii][jj] ii = 1-ii f = factor(c) cs.append(c) for k,v in f.items(): kv.setdefault(k,0) kv[k] = max(kv[k], v) ans = 1 for k,v in kv.items(): ans *= pow(k,v,M) ans %= M print(ans%M)