結果

問題 No.83 最大マッチング
ユーザー SagTokiSagToki
提出日時 2018-05-18 09:28:03
言語 Java21
(openjdk 21)
結果
AC  
実行時間 409 ms / 5,000 ms
コード長 1,238 bytes
コンパイル時間 5,416 ms
コンパイル使用メモリ 72,628 KB
実行使用メモリ 64,940 KB
最終ジャッジ日時 2023-09-10 22:50:09
合計ジャッジ時間 8,871 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
55,664 KB
testcase_01 AC 127 ms
55,744 KB
testcase_02 AC 128 ms
55,812 KB
testcase_03 AC 127 ms
53,840 KB
testcase_04 AC 128 ms
55,916 KB
testcase_05 AC 128 ms
55,804 KB
testcase_06 AC 128 ms
55,640 KB
testcase_07 AC 129 ms
55,516 KB
testcase_08 AC 126 ms
55,336 KB
testcase_09 AC 228 ms
56,240 KB
testcase_10 AC 360 ms
64,772 KB
testcase_11 AC 409 ms
64,940 KB
testcase_12 AC 400 ms
64,596 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.util.InputMismatchException;

public class MaximumMatching {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        try{
            //数値を入力して範囲をチェックする
            int N = scanner.nextInt();
            if(N < 2 || N > Math.pow(10,5)){
                System.out.println("Nは2以上10の5乗以下で入力してください");
                System.exit(0);
            }
            
            //入力された値が偶数か奇数かのチェック
            if( N % 2 == 0){
                for(int i = 0 ; i < N / 2 ; i++){
                    System.out.print("1");    
                    }
            }else{
                for(int j = 0 ; j < (N - 1) / 2 ; j++){
                    if( j == 0){
                        System.out.print("7");
                    }else{
                        System.out.print("1");
                    }
                }
            }
            
        }catch(InputMismatchException e){
            System.out.println("数字を入力してください");
        }catch(Exception E){
            System.out.println("予期せぬエラーです");
        }
    }
}
0