結果

問題 No.378 名声値を稼ごう
ユーザー 826814741_6826814741_6
提出日時 2019-03-14 01:09:24
言語 Bash
(Bash 5.1.16)
結果
AC  
実行時間 5 ms / 2,000 ms
コード長 262 bytes
コンパイル時間 49 ms
コンパイル使用メモリ 5,324 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-14 12:08:21
合計ジャッジ時間 625 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
4,376 KB
testcase_01 AC 3 ms
4,380 KB
testcase_02 AC 4 ms
4,380 KB
testcase_03 AC 4 ms
4,380 KB
testcase_04 AC 4 ms
4,376 KB
testcase_05 AC 3 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

abs () {
	[ $1 -lt 0 ] && printf $((-1 * $1)) || printf $1
}

f () {
	local a=$1; local b=$1; local c=$1
	while [ $a -ne 0 ]; do
		[ $(($a + $a)) -gt $c ] && c=$(($a + $a))
		a=$(($a >> 1)); b=$(($a + $b))
	done
	printf $(abs $(($b - $c)))
}

read n
echo $(f $n)
0