結果

問題 No.1185 完全な3の倍数
ユーザー 萩3
提出日時 2021-05-03 01:15:55
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 886 bytes
コンパイル時間 200 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 52,608 KB
最終ジャッジ日時 2024-07-21 10:29:57
合計ジャッジ時間 3,383 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27 WA * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
import sys

def resolve():
    nstr = input()
    length = len(nstr)
    n = int(nstr)

    if length == 2:
        print(n//3-3)
        return

    result = 30
    
    if length - 3 > 0:
        result += 16*(4**(length-3)-1)

    head = int(nstr[0])
    if head < 3:
        print(result)
        return
    elif head == 3:
        pass
    elif head < 6:
        result += 4**(length-1)
        print(result)
        return
    elif head == 6:
        result += 4**(length-1)
    elif head < 9:
        result += 2 * 4**(length-1)
        print(result)
        return
    else:
        result += 2 * 4**(length-1)

    tmp = 1
    for c in nstr[1:]:
        if int(c) < 3:
            continue
        elif int(c) < 6:
            tmp *= 2
        elif int(c) < 9:
            tmp *= 3
        else:
            tmp *= 4

    result += tmp
    print(result)

resolve()
0