結果
問題 | No.589 Counting Even |
ユーザー |
|
提出日時 | 2017-11-09 03:27:19 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 144 ms / 2,000 ms |
コード長 | 841 bytes |
コンパイル時間 | 2,493 ms |
コンパイル使用メモリ | 74,932 KB |
実行使用メモリ | 41,628 KB |
最終ジャッジ日時 | 2024-11-24 06:21:16 |
合計ジャッジ時間 | 8,510 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 29 |
ソースコード
import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { new Main().run(); } static long[][] c = new long[10][10]; { c[0][0] = 1; for (int i = 1; i < 10; ++i) { for (int j = 0; j <= i; ++j) { c[i][j] = c[i - 1][j] + (j > 0 ? c[i - 1][j - 1] : 0); // if (c[i][j] % 2 == 0) { // System.out.println(Integer.toBinaryString(i)); // System.out.println(Integer.toBinaryString(j)); // System.out.println(); // } } } } static void run() { Scanner sc = new Scanner(System.in); long n = sc.nextLong(); int[] cnt = new int[2]; long d = n; while (d > 0) { ++cnt[(int) (d % 2)]; d /= 2; } System.out.println((n + 1) - (1L << cnt[1])); } static void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }