結果
問題 | No.757 チャンパーノウン定数 (2) |
ユーザー |
|
提出日時 | 2018-12-05 16:40:53 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 565 bytes |
コンパイル時間 | 173 ms |
コンパイル使用メモリ | 82,224 KB |
実行使用メモリ | 71,244 KB |
最終ジャッジ日時 | 2024-07-19 06:36:19 |
合計ジャッジ時間 | 4,129 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 RE * 1 |
other | AC * 37 RE * 14 |
ソースコード
def power(p,n): if n == 0: return 1 elif n%2==0: return power(p*p,n/2) else: return power(p,n-1)*p B = int(input()) D = int(input(), B) if D < B: print(D) exit(0) inf = -1 sup = 100000 while sup-inf > 1: mid = (sup+inf)//2 v = mid*power(B, mid)-(power(B,mid)-1)//(B-1) if v < D: inf = mid else: sup = mid # print(inf,sup) D -= inf*power(B,inf)-(power(B,inf)-1)//(B-1) D -= 1 num = D//sup d = D%sup NUM = power(B,inf)+num # print(NUM) NUM //= power(B,inf-d) # print("d=",d) print(NUM%B)