結果

問題 No.499 7進数変換
ユーザー pluto77pluto77
提出日時 2017-04-09 14:44:37
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 668 bytes
コンパイル時間 115 ms
コンパイル使用メモリ 7,040 KB
実行使用メモリ 6,812 KB
最終ジャッジ日時 2024-07-18 01:29:42
合計ジャッジ時間 1,380 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 30 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

def base_str(n, radix):
    digits = "0123456789abcdefghijklmnopqrstuvwxyz"

    def num_check(attr, i):
        try:
            return int(i)
        except:
            raise ValueError('invalid %s : %s' % (attr, i))

    n = num_check('n', n)
    radix = num_check('radix', radix)

    if not 1 < radix < 37:
        raise ValueError('invalid radix %s' % radix)

    is_negative = n < 0
    n = abs(n)
    result = []

    while n:
        result.insert(0, n % radix)
        n /= radix
        if n == 0:
            break

    s = ''. join([digits[i] for i in result])
    if is_negative:
        s = '-' + s
    return s

n=int(raw_input())
print base_str(n,7)
0