結果

問題 No.589 Counting Even
ユーザー uafr_cs
提出日時 2017-11-03 23:05:03
言語 Java
(openjdk 23)
結果
AC  
実行時間 137 ms / 2,000 ms
コード長 484 bytes
コンパイル時間 2,363 ms
コンパイル使用メモリ 74,496 KB
実行使用メモリ 41,844 KB
最終ジャッジ日時 2024-11-23 14:46:43
合計ジャッジ時間 7,493 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

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