結果

問題 No.1185 完全な3の倍数
ユーザー tonyu0tonyu0
提出日時 2020-08-22 15:06:27
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 432 ms / 2,000 ms
コード長 785 bytes
コンパイル時間 123 ms
コンパイル使用メモリ 10,560 KB
実行使用メモリ 52,092 KB
最終ジャッジ日時 2023-08-16 00:10:05
合計ジャッジ時間 9,423 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 384 ms
45,400 KB
testcase_01 AC 17 ms
8,460 KB
testcase_02 AC 18 ms
8,644 KB
testcase_03 AC 360 ms
43,068 KB
testcase_04 AC 402 ms
49,060 KB
testcase_05 AC 389 ms
46,020 KB
testcase_06 AC 365 ms
43,848 KB
testcase_07 AC 358 ms
43,064 KB
testcase_08 AC 428 ms
52,092 KB
testcase_09 AC 16 ms
8,484 KB
testcase_10 AC 17 ms
8,480 KB
testcase_11 AC 17 ms
8,584 KB
testcase_12 AC 16 ms
8,480 KB
testcase_13 AC 16 ms
8,640 KB
testcase_14 AC 16 ms
8,616 KB
testcase_15 AC 16 ms
8,568 KB
testcase_16 AC 17 ms
8,628 KB
testcase_17 AC 18 ms
8,444 KB
testcase_18 AC 18 ms
8,444 KB
testcase_19 AC 119 ms
16,276 KB
testcase_20 AC 345 ms
39,936 KB
testcase_21 AC 229 ms
28,192 KB
testcase_22 AC 151 ms
19,184 KB
testcase_23 AC 119 ms
16,236 KB
testcase_24 AC 334 ms
39,900 KB
testcase_25 AC 46 ms
10,372 KB
testcase_26 AC 234 ms
28,012 KB
testcase_27 AC 123 ms
16,248 KB
testcase_28 AC 245 ms
29,588 KB
testcase_29 AC 200 ms
25,116 KB
testcase_30 AC 223 ms
28,036 KB
testcase_31 AC 21 ms
8,956 KB
testcase_32 AC 392 ms
46,020 KB
testcase_33 AC 90 ms
13,904 KB
testcase_34 AC 342 ms
39,944 KB
testcase_35 AC 432 ms
48,964 KB
testcase_36 AC 357 ms
39,980 KB
testcase_37 AC 350 ms
39,980 KB
testcase_38 AC 234 ms
28,108 KB
testcase_39 AC 18 ms
8,628 KB
testcase_40 AC 17 ms
8,472 KB
testcase_41 AC 19 ms
8,536 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
n = int(input())
# まず3の倍数なら桁話は3の倍数
#
# 1212ダメ
# 3の倍数でないものが現れるのは2桁の時のみ?
# 1515 - 11でダメ
# 3桁以上だと3の倍数以外が桁に現れると条件を満たさない?
# 3の倍数のうち、3の倍数のみが桁に現れるものの数
# -> 桁DPでもいいけど全部列挙できる

# 2桁は全部見つける、1桁は最後に除外
two = [12, 15, 18, 21, 24, 27, 42, 45, 48, 51, 54, 57, 72, 75, 78, 81, 84, 87]
ans = 0
q = deque()
q.append(3)
q.append(6)
q.append(9)
while len(q) > 0:
    x = q.popleft()
    if x > n:
        continue
    ans += 1
    for y in [0, 3, 6, 9]:
        q.append(x * 10 + y)

for t in two:
    if t <= n:
        ans += 1
print(ans - 3)
0