結果

問題 No.589 Counting Even
ユーザー uafr_csuafr_cs
提出日時 2017-11-03 23:05:03
言語 Java21
(openjdk 21)
結果
AC  
実行時間 133 ms / 2,000 ms
コード長 484 bytes
コンパイル時間 2,356 ms
コンパイル使用メモリ 72,028 KB
実行使用メモリ 56,020 KB
最終ジャッジ日時 2023-08-15 08:53:42
合計ジャッジ時間 7,835 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
55,884 KB
testcase_01 AC 132 ms
55,880 KB
testcase_02 AC 133 ms
55,852 KB
testcase_03 AC 129 ms
55,468 KB
testcase_04 AC 131 ms
55,840 KB
testcase_05 AC 128 ms
55,968 KB
testcase_06 AC 129 ms
55,860 KB
testcase_07 AC 128 ms
55,676 KB
testcase_08 AC 129 ms
55,408 KB
testcase_09 AC 129 ms
55,824 KB
testcase_10 AC 129 ms
55,708 KB
testcase_11 AC 128 ms
55,688 KB
testcase_12 AC 127 ms
55,708 KB
testcase_13 AC 130 ms
55,608 KB
testcase_14 AC 127 ms
55,964 KB
testcase_15 AC 131 ms
56,020 KB
testcase_16 AC 131 ms
55,748 KB
testcase_17 AC 128 ms
55,916 KB
testcase_18 AC 128 ms
55,412 KB
testcase_19 AC 127 ms
55,640 KB
testcase_20 AC 130 ms
55,712 KB
testcase_21 AC 128 ms
55,928 KB
testcase_22 AC 129 ms
55,480 KB
testcase_23 AC 129 ms
55,812 KB
testcase_24 AC 127 ms
55,716 KB
testcase_25 AC 128 ms
55,844 KB
testcase_26 AC 127 ms
55,840 KB
testcase_27 AC 128 ms
55,504 KB
testcase_28 AC 127 ms
55,860 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	
	public static long solve(long n){
		if(n == 0){ 
			return 0;
		}else if(n == 1){
			return 0;
		}else if(n % 2 == 0){
			return (n / 2) + solve(n / 2);
		}else{
			return solve(n / 2) * 2;
		}
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		final long N = sc.nextLong();
		
		System.out.println(solve(N));
	}
}
0