結果

問題 No.83 最大マッチング
ユーザー Tetsuya Ohira
提出日時 2020-02-10 18:04:11
言語 Go
(1.23.4)
結果
AC  
実行時間 162 ms / 5,000 ms
コード長 514 bytes
コンパイル時間 11,089 ms
コンパイル使用メモリ 222,808 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2024-10-01 06:27:56
合計ジャッジ時間 12,127 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

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