結果
問題 |
No.354 メルセンヌ素数
|
ユーザー |
![]() |
提出日時 | 2016-04-01 23:32:52 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 444 bytes |
コンパイル時間 | 2,097 ms |
コンパイル使用メモリ | 74,708 KB |
実行使用メモリ | 56,024 KB |
最終ジャッジ日時 | 2024-10-02 09:23:25 |
合計ジャッジ時間 | 4,606 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 1 WA * 12 |
ソースコード
import java.util.Scanner; class Main { public static void main(String[] args) throws Exception { Scanner in = new Scanner(System.in); int p = in.nextInt(); int temp = (int)(Math.pow(2, p)) - 1; String val2 = Integer.toBinaryString(temp); int 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); } }