結果
問題 | No.757 チャンパーノウン定数 (2) |
ユーザー | yuppe19 😺 |
提出日時 | 2018-12-05 13:58:25 |
言語 | PyPy2 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,723 bytes |
コンパイル時間 | 1,851 ms |
コンパイル使用メモリ | 77,396 KB |
実行使用メモリ | 89,408 KB |
最終ジャッジ日時 | 2023-09-25 20:15:56 |
合計ジャッジ時間 | 24,229 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 73 ms
76,512 KB |
testcase_01 | AC | 72 ms
76,560 KB |
testcase_02 | AC | 73 ms
76,244 KB |
testcase_03 | AC | 74 ms
76,248 KB |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | AC | 73 ms
76,676 KB |
testcase_07 | AC | 73 ms
76,288 KB |
testcase_08 | WA | - |
testcase_09 | AC | 72 ms
76,592 KB |
testcase_10 | AC | 75 ms
76,472 KB |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | AC | 72 ms
76,268 KB |
testcase_15 | AC | 74 ms
76,412 KB |
testcase_16 | AC | 74 ms
76,676 KB |
testcase_17 | AC | 73 ms
76,296 KB |
testcase_18 | AC | 74 ms
76,568 KB |
testcase_19 | AC | 74 ms
76,568 KB |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | AC | 74 ms
76,712 KB |
testcase_23 | WA | - |
testcase_24 | AC | 73 ms
76,492 KB |
testcase_25 | WA | - |
testcase_26 | AC | 77 ms
76,276 KB |
testcase_27 | AC | 74 ms
76,720 KB |
testcase_28 | AC | 1,627 ms
83,848 KB |
testcase_29 | WA | - |
testcase_30 | AC | 81 ms
79,276 KB |
testcase_31 | AC | 117 ms
79,276 KB |
testcase_32 | AC | 80 ms
79,068 KB |
testcase_33 | AC | 117 ms
78,832 KB |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | AC | 91 ms
79,304 KB |
testcase_37 | AC | 1,012 ms
80,924 KB |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | TLE | - |
testcase_41 | TLE | - |
testcase_42 | AC | 914 ms
79,432 KB |
testcase_43 | TLE | - |
testcase_44 | AC | 1,954 ms
86,380 KB |
testcase_45 | AC | 1,461 ms
82,772 KB |
testcase_46 | AC | 1,928 ms
81,644 KB |
testcase_47 | AC | 1,695 ms
84,820 KB |
testcase_48 | AC | 1,074 ms
80,668 KB |
testcase_49 | AC | 1,688 ms
84,216 KB |
testcase_50 | WA | - |
testcase_51 | WA | - |
testcase_52 | AC | 77 ms
76,676 KB |
testcase_53 | AC | 75 ms
76,940 KB |
ソースコード
#!/usr/bin/python2 # -*- coding: utf-8 -*- # † import string from math import log # 基数変換. 10進数の{num}を{base}進数にします。 def int2base(num, base, digits=string.digits+string.ascii_uppercase): assert base > 1 is_negative = num < 0 num = abs(num) if num == 0: return digits[0] s = '' while num != 0: s = digits[num % base] + s num /= base if is_negative: s = '-' + s return s # 基数変換. {base}進数で表現された{s}を10進数にします。 #base2int = lambda s, base: int(s, base) def base2int(s, base, digits=string.digits+string.ascii_uppercase): if len(s) == 0: return 0 is_negative = s[0] == '-' if is_negative: s = s[1:] num = 0 for c in s: num *= base num += digits.index(c) if is_negative: num *= -1 return num # s <= t か def leq(s, t): n1 = len(s) n2 = len(t) if n1 < n2: return True if n1 > n2: return False for i in xrange(n1): if ord(s[i]) > ord(t[i]): return False return True # i文字の開始位置 def create(B, i): if i == 1: return '10' res = int2base(i-1, B) + str(B-2) * (i-2) + str(B-1) + '0' return res def f(B, D): DB = base2int(D, B) lo, hi = 0, len(D) while hi - lo > 1: md = (lo + hi) / 2 if leq(create(B, md), D): lo = md else: hi = md x = base2int(create(B, lo), B) z, r = divmod(DB-x, hi) w = z + B**lo m = int(log(w, B)) + 1 # p = int2base(w, B) # return p[r] return (w / B**(m-1-r)) % B B = int(raw_input()) D = raw_input() res = f(B, D) print res