結果

問題 No.83 最大マッチング
ユーザー PraiPrai
提出日時 2018-10-26 19:57:39
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 4 ms / 5,000 ms
コード長 893 bytes
コンパイル時間 381 ms
コンパイル使用メモリ 55,844 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-29 22:03:18
合計ジャッジ時間 933 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

/*あなたは「最大マッチング問題」という有名問題に取り組んでいる。
これは、何本かのマッチ棒が与えられたとき、それらを並べて表記できる最大の数を求める問題である。

数の表記は、0 から 9 までの数字を横に並べることによって行う。
数字の表記法は下図の通りである。
*/

#include<iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;

    if(n % 2 == 1){
        cout << 7;
        n -= 3;				//7を作るのに3本
    }

    while(n){
        cout << 1;
        n -= 2;				//1を作るのに1本
    }

    cout << endl;
    
    return 0;
}

/*
0→6本
1→2本	☆
2→5本
3→5本
4→4本	☆
5→5本	☆
6→6本	
7→3本	☆
8→7本	☆
9→6本	☆

桁数を稼ぐことを考えるとできるだけ1を作って次に7を作るのがいいかな
*/
0