結果
| 問題 |
No.757 チャンパーノウン定数 (2)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-12-02 03:23:04 |
| 言語 | Crystal (1.14.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 843 bytes |
| コンパイル時間 | 1,179 ms |
| コンパイル使用メモリ | 218,068 KB |
| 最終ジャッジ日時 | 2024-11-14 20:41:23 |
| 合計ジャッジ時間 | 1,563 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
[2mShowing last frame. Use --error-trace for full trace.[0m
In [4mMain.cr:35:5[0m
[2m 35 | [0m[1md.times{num/=base}[0m
[32;1m^----[0m
[33;1mError: undefined method 'times' for BigFloat[33;1m (compile-time type is (BigFloat | BigInt))[0m[0m
ソースコード
#!/usr/bin/env crystal
require "big/big_int"
starting=1
base=BigInt.new(gets.not_nil!)
while (s=gets)!=nil
n=BigInt.new(s.not_nil!,base: base)+(starting-2)
digits=1
expbase=BigInt.new("1")
if false
while (x=expbase*(digits*(base-1)))<=n
digits+=1
expbase*=base
n-=x
end
else
if false
while digits*base**digits-(base**digits-1)/(base-1)<=n
digits+=1
end
elsif false
digits=1+(s.not_nil!.size.downto(0).find{|digits|
z=base**digits;z*digits-(z-1)/(base-1)<=n
}||0)
else
digits=(1..s.not_nil!.size).bsearch{|digits|
z=base**digits;z*digits-(z-1)/(base-1)>n
}||s.not_nil!.size
end
expbase=base**(digits-1)
n-=(digits-1)*expbase-(expbase-1)/(base-1)
end
num=expbase+n/digits
d=digits-1-n%digits
if false
d.times{num/=base}
puts num%base
else
puts num.to_s(base)[-d-1]
end
end