結果

問題 No.524 コインゲーム
ユーザー ぴろず
提出日時 2017-06-02 22:57:11
言語 Java
(openjdk 23)
結果
AC  
実行時間 153 ms / 1,000 ms
コード長 654 bytes
コンパイル時間 2,596 ms
コンパイル使用メモリ 74,664 KB
実行使用メモリ 54,364 KB
最終ジャッジ日時 2024-10-02 10:22:30
合計ジャッジ時間 8,770 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

package no524;

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		boolean zero = true;
		for(int i=0;i<=31;i++) {
			long cycle = (n+1) / (1L << (i+1));
			long reminder = (n+1) - cycle * (1L << (i+1));
			long sum = cycle * (1L << i) + Math.max(0, reminder - (1L << i));
			if (sum % 2 == 1) {
				zero = false;
				break;
			}
		}
		System.out.println(zero ? "X" : "O");
	}
	
	public static void test() {
		long sum = 0;
		for(long i=0;i<1000;i++) {
			sum ^= i;
			if (sum == 0) {
				System.out.println(Long.toBinaryString(i));
			}
		}
	}

}
0