結果
問題 |
No.1185 完全な3の倍数
|
ユーザー |
![]() |
提出日時 | 2025-03-18 22:42:16 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 105 ms / 2,000 ms |
コード長 | 631 bytes |
コンパイル時間 | 342 ms |
コンパイル使用メモリ | 82,244 KB |
実行使用メモリ | 76,412 KB |
最終ジャッジ日時 | 2025-03-18 22:42:21 |
合計ジャッジ時間 | 4,972 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 39 |
ソースコード
from itertools import pairwise def digits(x: int) -> list[int]: return [int(c) for c in str(x)] def conv(x: int) -> int: if x == 0: return 0 ds = [] while x > 0: ds.append(x % 4) x //= 4 res = 0 for d in reversed(ds): res = 10*res + d*3 return res N = int(input()) ans = 0 for i in range(10, min(100, N+1)): # 100以下は全探索 if i % 3 != 0: continue if all((a+b) % 3 == 0 for a, b in pairwise(digits(i))): ans += 1 # 4進数で全探索 for i in range(1, N+1): x = conv(i) if x < 100: continue if x > N: break ans += 1 print(ans)