結果

問題 No.354 メルセンヌ素数
ユーザー jimanojimano
提出日時 2018-02-11 12:01:14
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 506 bytes
コンパイル時間 2,787 ms
コンパイル使用メモリ 73,196 KB
実行使用メモリ 37,072 KB
最終ジャッジ日時 2024-04-27 15:08:29
合計ジャッジ時間 4,191 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
36,616 KB
testcase_01 AC 45 ms
36,916 KB
testcase_02 AC 44 ms
36,888 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 #

package me.yukicoder;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class No0354 {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		long num = (long) Math.pow(2.0, n) - 1;
		int cnt = 0;

		for (char c : Long.toBinaryString(num).toCharArray()) {
			cnt = c == '1' ? cnt + 1 : cnt;
		}
		System.out.println(cnt);
	}
}
0