結果

問題 No.354 メルセンヌ素数
ユーザー matsuyoshi30matsuyoshi30
提出日時 2016-04-01 23:36:59
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 446 bytes
コンパイル時間 2,557 ms
コンパイル使用メモリ 74,888 KB
実行使用メモリ 55,884 KB
最終ジャッジ日時 2024-04-10 08:08:40
合計ジャッジ時間 5,088 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
54,144 KB
testcase_01 AC 122 ms
53,984 KB
testcase_02 AC 117 ms
53,908 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

class Main {
	public static void main(String[] args) throws Exception {
		Scanner in = new Scanner(System.in);
		long p = in.nextLong();

		long temp = (long)(Math.pow(2, p)) - 1;
		String val2 = Long.toBinaryString(temp);
		long n = val2.length();
		int ans = 0;
		for(int i=0; i<n; i++) {
			char c = val2.charAt(i);
			String s = String.valueOf(c);
			ans += Integer.parseInt(s);
		}

		System.out.println(ans);
	}
}
0