結果

問題 No.481 1から10
ユーザー tsunabittsunabit
提出日時 2018-04-15 13:44:29
言語 Java21
(openjdk 21)
結果
AC  
実行時間 126 ms / 2,000 ms
コード長 1,251 bytes
コンパイル時間 3,183 ms
コンパイル使用メモリ 73,088 KB
実行使用メモリ 56,292 KB
最終ジャッジ日時 2023-09-09 05:43:06
合計ジャッジ時間 5,153 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
55,920 KB
testcase_01 AC 121 ms
55,912 KB
testcase_02 AC 121 ms
55,868 KB
testcase_03 AC 122 ms
56,284 KB
testcase_04 AC 122 ms
55,764 KB
testcase_05 AC 123 ms
55,904 KB
testcase_06 AC 125 ms
55,888 KB
testcase_07 AC 123 ms
56,292 KB
testcase_08 AC 124 ms
56,012 KB
testcase_09 AC 126 ms
56,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;


// 問題文
// A君は左から右に1から10までの数を書くことを試みました。
// しかし、A君は書いた数が9個しかないことに気づきました。
// どうやら書くべき数を1つ書かなかったようです。
// A君が書かなかった数は何でしょうか?
// ***
// 入力
// B1 B2 … B9
// 入力される数の個数はちょうど9個。
// Biは左からi番目の整数。1≤Bi≤10。
// Biの値はすべて異なり、左から右に昇順である。
// ***
// 出力
// 答えとなる数を1行で出力し最後に改行せよ。

public class No489 {
    public static void main(String[] args) {
        // 標準入力から読み込む際に、Scannerオブジェクトを使う。
        Scanner sc = new Scanner(System.in);
        int pre = 0;
        int input;
        boolean flag = false;
        for(int i = 0; i < 9; i++) {
            input = sc.nextInt();
            if(pre + 1 != input) {
                pre += 1;
                flag = true;
                break;
            }else {
                pre = input;
            }
        }
        if(flag == false) {
            pre = 10;
        }
        System.out.println(pre);
    }
}
0