結果
| 問題 |
No.1185 完全な3の倍数
|
| コンテスト | |
| ユーザー |
norioc
|
| 提出日時 | 2025-03-18 23:31:02 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 206 ms / 2,000 ms |
| コード長 | 620 bytes |
| コンパイル時間 | 422 ms |
| コンパイル使用メモリ | 82,900 KB |
| 実行使用メモリ | 76,516 KB |
| 最終ジャッジ日時 | 2025-03-18 23:31:10 |
| 合計ジャッジ時間 | 6,504 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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:
base = 4
def rec(x: int, b: int) -> int:
if x == 0: return 0
m = (x % base) * b * 3
return m + rec(x//4, b*10)
return rec(x, 1)
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)
norioc