結果

問題 No.83 最大マッチング
ユーザー LeonardoneLeonardone
提出日時 2015-10-14 18:38:32
言語 Ruby
(3.3.0)
結果
AC  
実行時間 83 ms / 5,000 ms
コード長 768 bytes
コンパイル時間 57 ms
コンパイル使用メモリ 11,276 KB
実行使用メモリ 15,304 KB
最終ジャッジ日時 2023-09-28 13:07:58
合計ジャッジ時間 2,006 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
15,164 KB
testcase_01 AC 83 ms
15,148 KB
testcase_02 AC 82 ms
15,232 KB
testcase_03 AC 83 ms
15,144 KB
testcase_04 AC 81 ms
15,052 KB
testcase_05 AC 80 ms
15,036 KB
testcase_06 AC 79 ms
15,252 KB
testcase_07 AC 81 ms
15,252 KB
testcase_08 AC 81 ms
15,304 KB
testcase_09 AC 80 ms
15,040 KB
testcase_10 AC 82 ms
15,168 KB
testcase_11 AC 80 ms
15,180 KB
testcase_12 AC 80 ms
15,204 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

#! ruby
# yukicoder My Practice
# author: Leonardone @ NEETSDKASU

N = gets.to_i

# 頭の中を整理するためのメモ

# 各数字を作るのに必要な本数
# 0 ... 6本
# 1 ... 2本
# 2 ... 5
# 3 ... 5
# 4 ... 4
# 5 ... 5
# 6 ... 6
# 7 ... 3
# 8 ... 7
# 9 ... 6

# 上記より本数ごとに作れる数
# 2本 ... 1
# 3本 ... 1,7
# 4   ... 11,4,7
# 5   ... 11,17,2,3,4,5,71
# 6   ... 0,111,14,17,2,3,41,5,6,71,77,9
# 7   ... 0,111,117,12,13,14,15,171,21,31,41,47,51,57,6,711,77,8,9

# まぁ要するに
# 本数が偶数なら1を並べたものが最大、並べる本数はN/2
# 本数が奇数なら頭を7にして残り1を並べたものが最大、並べる本数はfloor(N/2)-1

if N.even?
	puts "1"*N.div(2)
else
	puts "7"+"1"*N.div(2).pred
end
0