結果
| 問題 |
No.757 チャンパーノウン定数 (2)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-12-02 02:45:48 |
| 言語 | Ruby (3.4.1) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 494 bytes |
| コンパイル時間 | 34 ms |
| コンパイル使用メモリ | 7,552 KB |
| 実行使用メモリ | 12,800 KB |
| 最終ジャッジ日時 | 2024-06-27 13:33:28 |
| 合計ジャッジ時間 | 6,710 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | RE * 3 |
| other | RE * 51 |
コンパイルメッセージ
Syntax OK
ソースコード
#!/usr/bin/ruby
starting=1
bse=gets.to_i
while gets
n=$_.to_i(bse)
n+=starting-2
digits=1
expbase=1
if false
while (x=expbase*(digits*(bse-1)))<=n
digits+=1
expbase*=bse
n-=x
end
else
while digits*expbase*base-(expbase*base-1)/(base-1)<=n
digits+=1
expbase*=base
end
n-=(digits-1)*expbase-(expbase-1)/(base-1)
end
num=expbase+n/digits
if false
d=digits-1-n%digits
d.times{num/=bse}
puts num%bse
else
puts num.to_s(bse)[-(digits-1-n%digits)-1]
end
end