結果
| 問題 |
No.1185 完全な3の倍数
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-10-25 13:56:13 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,071 bytes |
| コンパイル時間 | 191 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 11,136 KB |
| 最終ジャッジ日時 | 2024-07-03 13:04:44 |
| 合計ジャッジ時間 | 2,763 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 WA * 12 |
ソースコード
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()