結果

問題 No.757 チャンパーノウン定数 (2)
コンテスト
ユーザー ciel
提出日時 2018-12-02 02:50:39
言語 Ruby
(4.0.2)
コンパイル:
ruby -w -c _filename_
実行:
ruby _filename_
結果
WA  
実行時間 -
コード長 515 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 186 ms
コンパイル使用メモリ 9,088 KB
実行使用メモリ 109,192 KB
最終ジャッジ日時 2026-03-15 11:23:18
合計ジャッジ時間 52,858 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 1 TLE * 1
other AC * 13 WA * 23 TLE * 15
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #
raw source code

#!/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*(bse**digits)-(bse**digits-1)/(bse-1)<=n
			digits+=1
			#expbase*=bse
		end
		expbase=bse**digits
		n-=(digits-1)*expbase-(expbase-1)/(bse-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
0