結果

問題 No.83 最大マッチング
ユーザー mijimemijime
提出日時 2016-06-11 17:44:42
言語 Go
(1.22.1)
結果
AC  
実行時間 73 ms / 5,000 ms
コード長 647 bytes
コンパイル時間 10,395 ms
コンパイル使用メモリ 212,912 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-01 13:31:40
合計ジャッジ時間 11,339 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 9 ms
4,380 KB
testcase_10 AC 53 ms
4,380 KB
testcase_11 AC 73 ms
4,376 KB
testcase_12 AC 73 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"fmt"
	"io"
	"os"
)

func main() {
	resolve(os.Stdout, os.Stdin)
}

func writeOne(w io.Writer, num int) error {
	for i := 0; i < num; i++ {
		_, e := fmt.Fprint(w, "1")
		if e != nil {
			return e
		}
	}
	return nil
}

func resolve(w io.Writer, r io.Reader) error {
	var match int
	_, e := fmt.Fscanf(r, "%d", &match)

	if e != nil && e != io.EOF {
		return e
	}

	if match%2 == 0 {
		e := writeOne(w, match/2)
		if e != nil {
			return e
		}
	} else {
		_, e := fmt.Fprint(w, "7")
		if e != nil {
			return e
		}
		ee := writeOne(w, ((match-1)/2 - 1))
		if ee != nil {
			return ee
		}

	}
	fmt.Fprintln(w)

	return nil
}
0