結果
| 問題 | No.1185 完全な3の倍数 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-11-09 02:47:48 |
| 言語 | PyPy3 (7.3.23) |
| 結果 |
AC
|
| 実行時間 | 151 ms / 2,000 ms |
| + 268µs | |
| コード長 | 672 bytes |
| 記録 | |
| コンパイル時間 | 498 ms |
| コンパイル使用メモリ | 95,852 KB |
| 実行使用メモリ | 142,408 KB |
| 最終ジャッジ日時 | 2026-08-23 09:39:34 |
| 合計ジャッジ時間 | 6,576 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_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)