結果

問題 No.593 4進FizzBuzz
ユーザー yumechi
提出日時 2017-11-24 22:02:51
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,268 bytes
コンパイル時間 233 ms
コンパイル使用メモリ 81,900 KB
実行使用メモリ 144,516 KB
最終ジャッジ日時 2024-11-27 07:11:56
合計ジャッジ時間 59,638 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 12 TLE * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

# please use positive value


def convert10toDecimal(
    num,  # expected Integer type
    decimal,  # expected Integer type
    characters="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",  # expected upper case
    lowercharacter=False
):

    # decimal only can use 2 to 36
    if num < 0 and not 2 <= decimal <= len(characters):
        return None

    convertedValue = ""
    while num > 0:
        convertedValue = \
            characters[num % decimal] + convertedValue
        num //= decimal
    return convertedValue

# please use positive value


def convertDecimalto10(
    numstr,  # expected String type
    decimal,  # expected String type
    characters="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"  # expected upper case
):

    # decimal only can use 2 to 36
    if not 2 <= decimal <= len(characters):
        return None

    numstr = numstr.upper()  # use characters upper case
    powercnt = 1
    decimal10value = 0
    for chara in numstr[::-1]:
        decimal10value += powercnt * characters.index(chara)
        powercnt *= decimal

    return decimal10value


def run():
    n = input()
    r = convertDecimalto10(numstr=n, decimal=4)
    print(((r % 3 == 0 and "Fizz" or  "") + (r % 5 == 0 and "Buzz" or "")) or n)

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