結果

問題 No.83 最大マッチング
ユーザー yuma25689yuma25689
提出日時 2016-01-02 22:24:04
言語 JavaScript
(node v21.7.1)
結果
AC  
実行時間 83 ms / 5,000 ms
コード長 831 bytes
コンパイル時間 54 ms
コンパイル使用メモリ 6,812 KB
実行使用メモリ 45,184 KB
最終ジャッジ日時 2024-04-21 01:17:47
合計ジャッジ時間 1,731 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
39,040 KB
testcase_01 AC 71 ms
39,296 KB
testcase_02 AC 69 ms
39,168 KB
testcase_03 AC 70 ms
39,040 KB
testcase_04 AC 68 ms
39,040 KB
testcase_05 AC 68 ms
39,168 KB
testcase_06 AC 68 ms
39,040 KB
testcase_07 AC 69 ms
39,168 KB
testcase_08 AC 73 ms
41,320 KB
testcase_09 AC 68 ms
39,296 KB
testcase_10 AC 83 ms
45,184 KB
testcase_11 AC 83 ms
45,184 KB
testcase_12 AC 83 ms
45,184 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

function Main(input) {

	var lines = input.split("\n");
	// N
	var stickCount=parseInt(lines[0]);

	// なるべく少ない本数で表せる数値の中で一番値の大きいもの(=1)で、なるべく桁を稼ぐ
	// 1を1つにつき2本消費
	// 問題の条件的に、2 <= stickCount
	var digitCount = parseInt(stickCount / 2);
	//console.log(digitCount);
	var lastEqualSeven = false;
	var rest = stickCount % 2;

	if( 0 < rest ) {
		// 1本余る場合は、最後の1桁だけ一本足して7にする
		if( 0 < digitCount )
		{
			lastEqualSeven = true;
		}
	}

	// 数の作成
	var strCount = "1";
	if( lastEqualSeven )
	{
		strCount = "7";
	}
	for( var i=1; i < digitCount; i++ )
	{
		strCount += "1";
	}

	//currentを出力
	console.log(strCount);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
0