結果

問題 No.1185 完全な3の倍数
ユーザー yakeshibayakeshiba
提出日時 2020-11-09 02:47:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 220 ms / 2,000 ms
コード長 672 bytes
コンパイル時間 289 ms
コンパイル使用メモリ 87,100 KB
実行使用メモリ 139,832 KB
最終ジャッジ日時 2023-09-29 21:52:33
合計ジャッジ時間 8,769 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 216 ms
139,736 KB
testcase_01 AC 94 ms
71,708 KB
testcase_02 AC 94 ms
71,768 KB
testcase_03 AC 211 ms
139,416 KB
testcase_04 AC 217 ms
139,772 KB
testcase_05 AC 214 ms
139,832 KB
testcase_06 AC 213 ms
139,668 KB
testcase_07 AC 214 ms
139,772 KB
testcase_08 AC 220 ms
139,612 KB
testcase_09 AC 91 ms
71,436 KB
testcase_10 AC 89 ms
71,568 KB
testcase_11 AC 90 ms
71,724 KB
testcase_12 AC 89 ms
71,348 KB
testcase_13 AC 91 ms
71,420 KB
testcase_14 AC 91 ms
71,416 KB
testcase_15 AC 91 ms
71,704 KB
testcase_16 AC 91 ms
71,716 KB
testcase_17 AC 91 ms
71,520 KB
testcase_18 AC 92 ms
71,724 KB
testcase_19 AC 134 ms
93,132 KB
testcase_20 AC 186 ms
116,236 KB
testcase_21 AC 173 ms
115,372 KB
testcase_22 AC 138 ms
93,176 KB
testcase_23 AC 136 ms
93,112 KB
testcase_24 AC 185 ms
116,076 KB
testcase_25 AC 111 ms
77,636 KB
testcase_26 AC 172 ms
115,684 KB
testcase_27 AC 135 ms
93,052 KB
testcase_28 AC 173 ms
116,352 KB
testcase_29 AC 143 ms
92,928 KB
testcase_30 AC 179 ms
115,444 KB
testcase_31 AC 103 ms
77,600 KB
testcase_32 AC 214 ms
139,592 KB
testcase_33 AC 113 ms
77,728 KB
testcase_34 AC 184 ms
116,304 KB
testcase_35 AC 217 ms
139,548 KB
testcase_36 AC 184 ms
116,288 KB
testcase_37 AC 184 ms
116,248 KB
testcase_38 AC 175 ms
115,572 KB
testcase_39 AC 90 ms
71,704 KB
testcase_40 AC 89 ms
71,520 KB
testcase_41 AC 97 ms
77,424 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
0