結果
問題 |
No.2772 Appearing Even Times
|
ユーザー |
|
提出日時 | 2024-05-31 23:02:34 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 599 bytes |
コンパイル時間 | 439 ms |
コンパイル使用メモリ | 82,852 KB |
実行使用メモリ | 269,288 KB |
最終ジャッジ日時 | 2024-12-21 01:16:39 |
合計ジャッジ時間 | 61,979 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 7 TLE * 12 |
ソースコード
import sys sys.setrecursionlimit(10 ** 5) n = input() M = 998244353 cache = {} def count(num, i, tight, nzseen, mask): if i >= len(num): return int(mask == 0 and nzseen) key = (i, tight, nzseen, mask) if key in cache: return cache[key] maxd = 9 if tight: maxd = int(num[i]) res = 0 for d in range(maxd + 1): newnzseen = nzseen or d != 0 res += count(num, i + 1, tight and d == maxd, newnzseen, mask ^ (1 << d) if newnzseen else mask) res %= M cache[key] = res return res print(count(n, 0, True, False, 0))