結果

問題 No.757 チャンパーノウン定数 (2)
ユーザー cielciel
提出日時 2020-08-23 13:43:51
言語 Crystal
(1.11.2)
結果
AC  
実行時間 22 ms / 2,000 ms
コード長 955 bytes
コンパイル時間 17,173 ms
コンパイル使用メモリ 263,216 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2023-09-13 12:00:01
合計ジャッジ時間 19,715 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,752 KB
testcase_01 AC 2 ms
4,768 KB
testcase_02 AC 2 ms
4,816 KB
testcase_03 AC 3 ms
4,716 KB
testcase_04 AC 2 ms
4,716 KB
testcase_05 AC 3 ms
4,768 KB
testcase_06 AC 2 ms
4,816 KB
testcase_07 AC 3 ms
4,768 KB
testcase_08 AC 2 ms
4,752 KB
testcase_09 AC 3 ms
4,708 KB
testcase_10 AC 2 ms
4,764 KB
testcase_11 AC 2 ms
4,816 KB
testcase_12 AC 3 ms
4,756 KB
testcase_13 AC 3 ms
4,792 KB
testcase_14 AC 2 ms
4,816 KB
testcase_15 AC 2 ms
4,708 KB
testcase_16 AC 3 ms
4,684 KB
testcase_17 AC 2 ms
4,804 KB
testcase_18 AC 2 ms
4,820 KB
testcase_19 AC 2 ms
4,728 KB
testcase_20 AC 3 ms
4,780 KB
testcase_21 AC 2 ms
4,788 KB
testcase_22 AC 3 ms
4,812 KB
testcase_23 AC 2 ms
4,824 KB
testcase_24 AC 3 ms
4,764 KB
testcase_25 AC 2 ms
4,728 KB
testcase_26 AC 2 ms
4,780 KB
testcase_27 AC 2 ms
4,816 KB
testcase_28 AC 13 ms
6,296 KB
testcase_29 AC 15 ms
6,284 KB
testcase_30 AC 3 ms
5,076 KB
testcase_31 AC 3 ms
5,056 KB
testcase_32 AC 3 ms
4,884 KB
testcase_33 AC 3 ms
5,332 KB
testcase_34 AC 7 ms
5,920 KB
testcase_35 AC 3 ms
5,064 KB
testcase_36 AC 3 ms
5,080 KB
testcase_37 AC 13 ms
5,996 KB
testcase_38 AC 12 ms
6,260 KB
testcase_39 AC 14 ms
6,264 KB
testcase_40 AC 19 ms
6,316 KB
testcase_41 AC 18 ms
6,240 KB
testcase_42 AC 5 ms
5,784 KB
testcase_43 AC 6 ms
6,168 KB
testcase_44 AC 22 ms
6,400 KB
testcase_45 AC 16 ms
6,280 KB
testcase_46 AC 5 ms
6,120 KB
testcase_47 AC 19 ms
6,320 KB
testcase_48 AC 11 ms
5,832 KB
testcase_49 AC 14 ms
6,376 KB
testcase_50 AC 2 ms
4,708 KB
testcase_51 AC 2 ms
4,792 KB
testcase_52 AC 3 ms
4,812 KB
testcase_53 AC 3 ms
4,768 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