結果

問題 No.354 メルセンヌ素数
ユーザー yagi2yagi2
提出日時 2017-04-17 16:58:40
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 444 bytes
コンパイル時間 1,957 ms
コンパイル使用メモリ 72,504 KB
実行使用メモリ 210,160 KB
最終ジャッジ日時 2023-09-26 10:47:21
合計ジャッジ時間 7,266 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
62,748 KB
testcase_01 AC 116 ms
55,928 KB
testcase_02 AC 118 ms
55,736 KB
testcase_03 AC 118 ms
55,832 KB
testcase_04 AC 139 ms
56,056 KB
testcase_05 AC 154 ms
56,324 KB
testcase_06 AC 196 ms
59,020 KB
testcase_07 AC 311 ms
66,364 KB
testcase_08 AC 783 ms
113,932 KB
testcase_09 TLE -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.math.BigInteger;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        BigInteger mersenne = new BigInteger("2").pow(Integer.parseInt(sc.next())).subtract(BigInteger.ONE);

        int cnt = 0;
        for (String s : mersenne.toString(2).split("")) {
            if (s.equals("1")) cnt++;
        }
        System.out.println(cnt);
    }
}
0