結果

問題 No.47 ポケットを叩くとビスケットが2倍
ユーザー sianfsianf
提出日時 2017-02-06 23:12:17
言語 Go
(1.22.1)
結果
AC  
実行時間 52 ms / 5,000 ms
コード長 432 bytes
コンパイル時間 12,014 ms
コンパイル使用メモリ 210,324 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-25 21:57:21
合計ジャッジ時間 12,358 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 28 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 33 ms
4,376 KB
testcase_09 AC 5 ms
4,376 KB
testcase_10 AC 45 ms
4,376 KB
testcase_11 AC 26 ms
4,376 KB
testcase_12 AC 21 ms
4,376 KB
testcase_13 AC 17 ms
4,380 KB
testcase_14 AC 35 ms
4,376 KB
testcase_15 AC 6 ms
4,376 KB
testcase_16 AC 11 ms
4,380 KB
testcase_17 AC 16 ms
4,376 KB
testcase_18 AC 5 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 13 ms
4,376 KB
testcase_21 AC 7 ms
4,376 KB
testcase_22 AC 16 ms
4,376 KB
testcase_23 AC 31 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)

	var current = 1
	var count int
	for count = 0; current != N; count++ {
		current = tap(current, N)
	}
	fmt.Println(count)
}

func tap(current, target int) int {
	var NUM int

	if current*2 <= target {
		NUM = current * 2
	} else {
		for i, j := current-1, 1; i > 0; i, j = i-1, j+1 {
			if j+i*2 <= target {
				NUM = j + i*2
				break
			}
		}
	}

	return NUM
}
0