結果

問題 No.757 チャンパーノウン定数 (2)
ユーザー cielciel
提出日時 2020-08-23 13:44:36
言語 Crystal
(1.11.2)
結果
AC  
実行時間 21 ms / 2,000 ms
コード長 956 bytes
コンパイル時間 17,224 ms
コンパイル使用メモリ 262,948 KB
実行使用メモリ 6,436 KB
最終ジャッジ日時 2023-09-13 12:00:46
合計ジャッジ時間 19,308 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,708 KB
testcase_01 AC 3 ms
4,752 KB
testcase_02 AC 3 ms
4,792 KB
testcase_03 AC 3 ms
4,768 KB
testcase_04 AC 3 ms
4,756 KB
testcase_05 AC 3 ms
4,812 KB
testcase_06 AC 3 ms
4,712 KB
testcase_07 AC 3 ms
4,712 KB
testcase_08 AC 2 ms
4,800 KB
testcase_09 AC 3 ms
4,796 KB
testcase_10 AC 3 ms
4,756 KB
testcase_11 AC 3 ms
4,760 KB
testcase_12 AC 3 ms
4,800 KB
testcase_13 AC 3 ms
4,816 KB
testcase_14 AC 3 ms
4,772 KB
testcase_15 AC 3 ms
4,792 KB
testcase_16 AC 3 ms
4,808 KB
testcase_17 AC 3 ms
4,772 KB
testcase_18 AC 3 ms
4,816 KB
testcase_19 AC 3 ms
4,732 KB
testcase_20 AC 3 ms
4,832 KB
testcase_21 AC 2 ms
4,736 KB
testcase_22 AC 2 ms
4,852 KB
testcase_23 AC 2 ms
4,724 KB
testcase_24 AC 2 ms
4,724 KB
testcase_25 AC 3 ms
4,724 KB
testcase_26 AC 2 ms
4,828 KB
testcase_27 AC 3 ms
4,824 KB
testcase_28 AC 13 ms
6,336 KB
testcase_29 AC 15 ms
6,268 KB
testcase_30 AC 3 ms
5,068 KB
testcase_31 AC 3 ms
5,080 KB
testcase_32 AC 2 ms
4,884 KB
testcase_33 AC 4 ms
5,280 KB
testcase_34 AC 7 ms
5,980 KB
testcase_35 AC 4 ms
5,064 KB
testcase_36 AC 3 ms
5,140 KB
testcase_37 AC 12 ms
5,888 KB
testcase_38 AC 12 ms
6,260 KB
testcase_39 AC 14 ms
6,380 KB
testcase_40 AC 19 ms
6,348 KB
testcase_41 AC 19 ms
6,264 KB
testcase_42 AC 5 ms
5,680 KB
testcase_43 AC 6 ms
6,124 KB
testcase_44 AC 21 ms
6,376 KB
testcase_45 AC 16 ms
6,296 KB
testcase_46 AC 6 ms
6,052 KB
testcase_47 AC 20 ms
6,276 KB
testcase_48 AC 12 ms
5,788 KB
testcase_49 AC 14 ms
6,436 KB
testcase_50 AC 3 ms
4,716 KB
testcase_51 AC 2 ms
4,812 KB
testcase_52 AC 3 ms
4,752 KB
testcase_53 AC 2 ms
4,712 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env crystal
lib C;fun strtoll(s: UInt8*,p: UInt8**,b: Int32): Int64;end
class String;def to_i64;C.strtoll(self,nil,10);end;end
require "big"
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