結果
| 問題 | No.1185 完全な3の倍数 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-11-09 02:47:48 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 128 ms / 2,000 ms |
| コード長 | 672 bytes |
| 記録 | |
| コンパイル時間 | 885 ms |
| コンパイル使用メモリ | 85,888 KB |
| 実行使用メモリ | 149,320 KB |
| 最終ジャッジ日時 | 2026-04-03 09:52:41 |
| 合計ジャッジ時間 | 4,280 ms |
|
ジャッジサーバーID (参考情報) |
judge5_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 39 |
ソースコード
from collections import deque
n = int(input())
if n < 100:
ans = 0
for i in range(10,n+1):
if i%3 == 0:
if (int(str(i)[0])+int(str(i)[1]))%3 == 0:
ans += 1
print(ans)
exit()
else:
ans = 30
q = deque([])
for i in range(10,100):
if i%3 == 0:
if int(str(i)[0])%3 == 0 and int(str(i)[1])%3 == 0:
q.append(str(i))
while q:
now = q.popleft()
if int(now) > n:
continue
if int(now) >= 100:
ans += 1
q.append(now+"3")
q.append(now+"6")
q.append(now+"9")
q.append(now+"0")
print(ans)