結果

問題 No.83 最大マッチング
ユーザー eagleeagle
提出日時 2022-06-08 14:14:08
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,324 bytes
コンパイル時間 4,664 ms
コンパイル使用メモリ 73,896 KB
実行使用メモリ 57,804 KB
最終ジャッジ日時 2023-10-21 04:02:12
合計ジャッジ時間 7,157 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 114 ms
57,496 KB
testcase_01 AC 111 ms
57,224 KB
testcase_02 AC 117 ms
57,356 KB
testcase_03 AC 110 ms
57,256 KB
testcase_04 AC 116 ms
57,248 KB
testcase_05 AC 106 ms
56,236 KB
testcase_06 AC 115 ms
57,284 KB
testcase_07 AC 121 ms
57,404 KB
testcase_08 AC 106 ms
56,336 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		//マッチの本数
		long N = sc.nextLong();
		//表記できる最大の数
		long pattern = 0;
		//残りのマッチの数
		long match = N;
		//ループの終了条件
		boolean flg = true;
		while(flg) {
			//桁数が大きくなるようにパターンを作成する
			//1を作れるか
			if(match / 2 != 0 && match % 2 == 0) {
				//1を作成
				pattern = pattern * 10 + 1;
				match -= 2;
			//7を作れるか
			} else if(match / 3 != 0) {
				//7を作成
				pattern = pattern * 10 + 7;
				match -= 3;
			//4を作れるか
			} else if(match / 4 != 0) {
				//4を作成
				pattern = pattern * 10 + 4;
				match -= 4;
			//5を作れるか
			} else if(match / 5 != 0) {
				//5を作成
				pattern = pattern * 10 + 5;
				match -= 5;
			//9を作れるか
			} else if(match / 6 != 0) {
				//9を作成
				pattern = pattern * 10 + 9;
				match -= 6;
			//8を作れるか
			} else if(match / 7 != 0) {
				//8を作成
				pattern = pattern * 10 + 8;
				match -= 7;
			//何も作れない場合
			} else {
				//ループを終了
				flg = false;
			}
		}
		//答え出力
		System.out.println(pattern);
	}
}
0