結果

問題 No.83 最大マッチング
ユーザー Tetsuya OhiraTetsuya Ohira
提出日時 2020-02-10 18:04:11
言語 Go
(1.22.1)
結果
AC  
実行時間 153 ms / 5,000 ms
コード長 514 bytes
コンパイル時間 13,196 ms
コンパイル使用メモリ 214,036 KB
実行使用メモリ 8,256 KB
最終ジャッジ日時 2024-04-08 13:08:03
合計ジャッジ時間 14,354 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 2 ms
6,548 KB
testcase_02 AC 1 ms
6,548 KB
testcase_03 AC 2 ms
6,548 KB
testcase_04 AC 2 ms
6,548 KB
testcase_05 AC 1 ms
6,548 KB
testcase_06 AC 2 ms
6,548 KB
testcase_07 AC 1 ms
6,548 KB
testcase_08 AC 1 ms
6,548 KB
testcase_09 AC 6 ms
8,128 KB
testcase_10 AC 82 ms
8,244 KB
testcase_11 AC 153 ms
8,256 KB
testcase_12 AC 151 ms
8,244 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import "fmt"

// 2 1
// 3 7
// 4 11
// 5 17
// 6 111
// 7 117
// 8 1111
// 9 1117
// 10 11111

// 20 1111111111
func main() {
	var n int
	fmt.Scan(&n)
	// 偶数の場合、2で割った数字ぶん1
	// 奇数の場合、2で割った数字ぶん1+7
	var result string
	if n == 3 {
		result = "7"
	} else if n%2 == 0 {
		// 偶数
		for i := 0; i < n/2; i++ {
			result += "1"
		}
	} else {
		// 奇数
		result += "7"
		for i := 0; i < (n-3)/2; i++ {
			result += "1"
		}
	}
	fmt.Println(result)
}
0