結果

問題 No.757 チャンパーノウン定数 (2)
ユーザー cielciel
提出日時 2020-02-08 22:28:16
言語 Crystal
(1.11.2)
結果
AC  
実行時間 23 ms / 2,000 ms
コード長 825 bytes
コンパイル時間 19,754 ms
コンパイル使用メモリ 263,156 KB
実行使用メモリ 6,468 KB
最終ジャッジ日時 2023-09-13 10:23:55
合計ジャッジ時間 22,383 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,860 KB
testcase_01 AC 3 ms
4,860 KB
testcase_02 AC 3 ms
4,920 KB
testcase_03 AC 3 ms
4,908 KB
testcase_04 AC 3 ms
4,860 KB
testcase_05 AC 3 ms
4,920 KB
testcase_06 AC 3 ms
4,764 KB
testcase_07 AC 3 ms
4,940 KB
testcase_08 AC 3 ms
4,880 KB
testcase_09 AC 3 ms
4,844 KB
testcase_10 AC 3 ms
4,824 KB
testcase_11 AC 3 ms
4,960 KB
testcase_12 AC 3 ms
4,892 KB
testcase_13 AC 2 ms
4,828 KB
testcase_14 AC 3 ms
4,908 KB
testcase_15 AC 3 ms
4,932 KB
testcase_16 AC 3 ms
4,920 KB
testcase_17 AC 3 ms
4,832 KB
testcase_18 AC 3 ms
4,816 KB
testcase_19 AC 3 ms
4,836 KB
testcase_20 AC 3 ms
4,920 KB
testcase_21 AC 3 ms
4,916 KB
testcase_22 AC 3 ms
4,812 KB
testcase_23 AC 3 ms
4,844 KB
testcase_24 AC 3 ms
4,932 KB
testcase_25 AC 3 ms
4,956 KB
testcase_26 AC 3 ms
4,836 KB
testcase_27 AC 3 ms
4,896 KB
testcase_28 AC 15 ms
6,352 KB
testcase_29 AC 17 ms
6,284 KB
testcase_30 AC 3 ms
5,204 KB
testcase_31 AC 3 ms
5,232 KB
testcase_32 AC 3 ms
5,076 KB
testcase_33 AC 4 ms
5,520 KB
testcase_34 AC 8 ms
6,056 KB
testcase_35 AC 3 ms
5,336 KB
testcase_36 AC 3 ms
5,036 KB
testcase_37 AC 13 ms
6,068 KB
testcase_38 AC 13 ms
6,468 KB
testcase_39 AC 14 ms
6,420 KB
testcase_40 AC 19 ms
6,408 KB
testcase_41 AC 19 ms
6,436 KB
testcase_42 AC 6 ms
5,900 KB
testcase_43 AC 7 ms
6,164 KB
testcase_44 AC 23 ms
6,280 KB
testcase_45 AC 18 ms
6,388 KB
testcase_46 AC 6 ms
6,180 KB
testcase_47 AC 20 ms
6,356 KB
testcase_48 AC 12 ms
6,072 KB
testcase_49 AC 14 ms
6,464 KB
testcase_50 AC 3 ms
4,828 KB
testcase_51 AC 3 ms
4,940 KB
testcase_52 AC 3 ms
4,900 KB
testcase_53 AC 3 ms
4,812 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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
0