結果
問題 | No.501 穴と文字列 |
ユーザー |
|
提出日時 | 2020-08-06 11:54:00 |
言語 | Go (1.23.4) |
結果 |
AC
|
実行時間 | 143 ms / 2,000 ms |
コード長 | 1,089 bytes |
コンパイル時間 | 10,573 ms |
コンパイル使用メモリ | 225,212 KB |
実行使用メモリ | 7,904 KB |
最終ジャッジ日時 | 2024-09-19 12:10:40 |
合計ジャッジ時間 | 11,891 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 22 |
ソースコード
package mainimport ("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}