結果

問題 No.192 合成数
ユーザー matsuyoshi30matsuyoshi30
提出日時 2016-02-12 12:20:23
言語 Java21
(openjdk 21)
結果
AC  
実行時間 120 ms / 2,000 ms
コード長 453 bytes
コンパイル時間 1,757 ms
コンパイル使用メモリ 71,648 KB
実行使用メモリ 56,572 KB
最終ジャッジ日時 2023-09-09 08:47:43
合計ジャッジ時間 6,320 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 115 ms
56,416 KB
testcase_01 AC 112 ms
55,812 KB
testcase_02 AC 112 ms
56,252 KB
testcase_03 AC 112 ms
56,092 KB
testcase_04 AC 113 ms
55,912 KB
testcase_05 AC 116 ms
55,876 KB
testcase_06 AC 115 ms
55,864 KB
testcase_07 AC 115 ms
56,160 KB
testcase_08 AC 112 ms
55,956 KB
testcase_09 AC 111 ms
55,964 KB
testcase_10 AC 112 ms
56,232 KB
testcase_11 AC 111 ms
56,080 KB
testcase_12 AC 112 ms
56,128 KB
testcase_13 AC 115 ms
55,924 KB
testcase_14 AC 117 ms
56,060 KB
testcase_15 AC 114 ms
55,704 KB
testcase_16 AC 115 ms
56,540 KB
testcase_17 AC 115 ms
56,572 KB
testcase_18 AC 112 ms
55,708 KB
testcase_19 AC 112 ms
56,336 KB
testcase_20 AC 114 ms
55,764 KB
testcase_21 AC 112 ms
56,160 KB
testcase_22 AC 115 ms
56,060 KB
testcase_23 AC 120 ms
56,492 KB
testcase_24 AC 112 ms
55,940 KB
testcase_25 AC 115 ms
55,984 KB
testcase_26 AC 114 ms
56,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

class Main {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int a = n - 98;
        in.close();

        while(true) {
            //Fermat test
            if((Math.pow(2, (a-1)) % a) != 1) {
                System.out.println(a);
                break;
            } else {
                a++;
            }
        }
    }
}
0