結果
問題 | No.2045 Two Reflections |
ユーザー | shotoyoo |
提出日時 | 2022-08-20 20:41:50 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,470 bytes |
コンパイル時間 | 214 ms |
コンパイル使用メモリ | 82,540 KB |
実行使用メモリ | 87,404 KB |
最終ジャッジ日時 | 2024-10-09 12:30:57 |
合計ジャッジ時間 | 3,891 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 46 ms
56,060 KB |
testcase_01 | AC | 47 ms
56,264 KB |
testcase_02 | AC | 104 ms
86,968 KB |
testcase_03 | AC | 138 ms
87,404 KB |
testcase_04 | AC | 134 ms
86,612 KB |
testcase_05 | AC | 59 ms
67,920 KB |
testcase_06 | AC | 59 ms
69,388 KB |
testcase_07 | AC | 135 ms
87,008 KB |
testcase_08 | AC | 119 ms
86,556 KB |
testcase_09 | AC | 78 ms
80,700 KB |
testcase_10 | AC | 63 ms
75,012 KB |
testcase_11 | AC | 96 ms
79,540 KB |
testcase_12 | WA | - |
testcase_13 | AC | 46 ms
56,164 KB |
testcase_14 | AC | 46 ms
56,312 KB |
testcase_15 | AC | 45 ms
56,364 KB |
testcase_16 | AC | 45 ms
56,128 KB |
testcase_17 | AC | 78 ms
81,516 KB |
testcase_18 | AC | 79 ms
81,584 KB |
testcase_19 | AC | 81 ms
81,536 KB |
testcase_20 | AC | 81 ms
81,288 KB |
testcase_21 | AC | 114 ms
87,140 KB |
testcase_22 | AC | 115 ms
86,856 KB |
testcase_23 | AC | 116 ms
87,104 KB |
testcase_24 | AC | 111 ms
86,828 KB |
testcase_25 | AC | 109 ms
87,080 KB |
testcase_26 | AC | 106 ms
87,248 KB |
testcase_27 | AC | 108 ms
86,920 KB |
testcase_28 | AC | 108 ms
86,852 KB |
testcase_29 | AC | 102 ms
87,276 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 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)