結果

問題 No.501 穴と文字列
ユーザー er-k-akier-k-aki
提出日時 2020-08-06 11:54:00
言語 Go
(1.22.1)
結果
AC  
実行時間 148 ms / 2,000 ms
コード長 1,089 bytes
コンパイル時間 11,523 ms
コンパイル使用メモリ 210,080 KB
実行使用メモリ 10,360 KB
最終ジャッジ日時 2023-10-19 16:01:53
合計ジャッジ時間 13,379 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func NextLine() string {
	sc.Scan()
	return sc.Text()
}
func NextInt() int {
	a, _ := strconv.Atoi(NextLine())
	return a
}

/**
 * スペース区切りで文字列を受け取って整数を2個返す
 */
func GetTwoInts() (a int, b int) {
	str := strings.Split(NextLine(), " ")
	a, _ = strconv.Atoi(str[0])
	b, _ = strconv.Atoi(str[1])
	return
}

func main() {
	N, D := GetTwoInts()
	fmt.Println(sToAABBCC(N, D))
}

/**
 * 文字列
 */
func sToAABBCC(N int, D int) (result string) {
	result = ""
	appender := "A"
	//最後の桁が2か1か0になれば良い
	//効率化の手段として残り桁数が3のとき残り数値が3ならAで埋めれば良い、残り数値が6ならBで埋めれば良い
	for i:=0; i< N; i++ {
		if D == 2 * (N - i){
			//fmt.Println("残りはBで埋められます", D)
			appender = "B"
		}else if D == 0 {
			//fmt.Println("残りはCで埋められます", D)
			appender = "C"
		}
		D--
		//fmt.Print(D)
		result += appender
	}
	return
}
0