結果

問題 No.1185 完全な3の倍数
ユーザー ThetaTheta
提出日時 2022-10-25 13:56:13
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,071 bytes
コンパイル時間 65 ms
コンパイル使用メモリ 10,876 KB
実行使用メモリ 8,944 KB
最終ジャッジ日時 2023-09-16 12:30:58
合計ジャッジ時間 2,297 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 20 ms
8,876 KB
testcase_02 AC 20 ms
8,772 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 20 ms
8,764 KB
testcase_09 AC 20 ms
8,688 KB
testcase_10 AC 21 ms
8,756 KB
testcase_11 AC 20 ms
8,700 KB
testcase_12 AC 20 ms
8,872 KB
testcase_13 AC 20 ms
8,736 KB
testcase_14 AC 20 ms
8,820 KB
testcase_15 AC 20 ms
8,816 KB
testcase_16 AC 20 ms
8,692 KB
testcase_17 AC 20 ms
8,744 KB
testcase_18 AC 20 ms
8,696 KB
testcase_19 AC 20 ms
8,748 KB
testcase_20 AC 19 ms
8,832 KB
testcase_21 AC 19 ms
8,816 KB
testcase_22 WA -
testcase_23 AC 20 ms
8,820 KB
testcase_24 AC 20 ms
8,884 KB
testcase_25 AC 20 ms
8,900 KB
testcase_26 AC 20 ms
8,880 KB
testcase_27 AC 20 ms
8,828 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 20 ms
8,760 KB
testcase_31 AC 20 ms
8,760 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 21 ms
8,884 KB
testcase_35 WA -
testcase_36 AC 19 ms
8,760 KB
testcase_37 AC 19 ms
8,732 KB
testcase_38 AC 20 ms
8,844 KB
testcase_39 AC 21 ms
8,672 KB
testcase_40 AC 20 ms
8,820 KB
testcase_41 AC 20 ms
8,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from functools import reduce
from math import log10, floor
from operator import mul

digit_pattern = {"0": 1, "1": 1, "2": 1, "3": 2, "4": 2, "5": 2, "6": 3,
                 "7": 3, "8": 3, "9": 4}


def main():
    N = int(input())
    if N < 12:
        print(0)
        return
    if N < 100:
        print((N - 12) // 3 + 1)
        return

    two_digit = 18

    over_two_digit = 4 ** floor(log10(N)) - 4

    last_digit = 0
    if int(str(N)[0]) == 3:
        last_digit = reduce(mul, map(digit_pattern.get, str(N)[1:]))
    elif 3 < int(str(N)[0]) < 6:
        last_digit = 4 ** floor(log10(N))
    elif int(str(N)[0]) == 6:
        last_digit = (reduce(mul, map(digit_pattern.get, str(N)[1:]))
                      + 4 ** floor(log10(N)))
    elif 6 < int(str(N)[0]) < 9:
        last_digit = 2 * 4 ** floor(log10(N))
    elif int(str(N)[0]) == 9:
        last_digit = (reduce(mul, map(digit_pattern.get, str(N)[1:]))
                      + 2 * 4 ** floor(log10(N)))

    print(two_digit + over_two_digit + last_digit)


if __name__ == "__main__":
    main()
0