結果

問題 No.756 チャンパーノウン定数 (1)
ユーザー cielciel
提出日時 2018-12-06 12:19:45
言語 OCaml
(5.1.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 674 bytes
コンパイル時間 353 ms
コンパイル使用メモリ 21,660 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-17 08:44:59
合計ジャッジ時間 997 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 1 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

let rec calc2 d num bse =
	if (Int64.compare d 0L)==0 then (Int64.rem num bse) else (calc2 (Int64.sub d 1L) (Int64.div num bse) bse);;

let rec calc digits expbase bse x n =
	if (Int64.compare x n)>0 then (calc2 (Int64.sub (Int64.sub digits 1L) (Int64.rem n digits)) (Int64.add expbase (Int64.div n digits)) bse) else (calc (Int64.add digits 1L) (Int64.mul expbase bse) bse (Int64.mul (Int64.mul (Int64.add digits 1L) (Int64.mul expbase bse)) (Int64.sub bse 1L)) (Int64.sub n x));;

try
	while true do
		Scanf.sscanf (read_line ()) "%Ld" (fun n ->
			print_string (Int64.to_string (calc 1L 1L 10L 9L (Int64.sub n 1L)));
			print_string "\n"
		)done;
with End_of_file -> ();;
0