結果
| 問題 |
No.1185 完全な3の倍数
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-11-09 02:47:48 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 187 ms / 2,000 ms |
| コード長 | 672 bytes |
| コンパイル時間 | 295 ms |
| コンパイル使用メモリ | 82,292 KB |
| 実行使用メモリ | 154,900 KB |
| 最終ジャッジ日時 | 2024-07-22 15:52:13 |
| 合計ジャッジ時間 | 6,227 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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)