結果

問題 No.524 コインゲーム
ユーザー ぴろずぴろず
提出日時 2017-06-02 22:57:11
言語 Java21
(openjdk 21)
結果
AC  
実行時間 120 ms / 1,000 ms
コード長 654 bytes
コンパイル時間 2,222 ms
コンパイル使用メモリ 74,284 KB
実行使用メモリ 54,420 KB
最終ジャッジ日時 2024-04-10 08:40:22
合計ジャッジ時間 6,980 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 112 ms
54,040 KB
testcase_01 AC 117 ms
54,312 KB
testcase_02 AC 115 ms
54,044 KB
testcase_03 AC 101 ms
54,420 KB
testcase_04 AC 113 ms
54,088 KB
testcase_05 AC 108 ms
53,380 KB
testcase_06 AC 107 ms
53,088 KB
testcase_07 AC 100 ms
52,580 KB
testcase_08 AC 114 ms
53,088 KB
testcase_09 AC 114 ms
54,208 KB
testcase_10 AC 108 ms
53,676 KB
testcase_11 AC 112 ms
54,372 KB
testcase_12 AC 106 ms
53,216 KB
testcase_13 AC 113 ms
54,092 KB
testcase_14 AC 116 ms
54,292 KB
testcase_15 AC 106 ms
52,824 KB
testcase_16 AC 115 ms
54,272 KB
testcase_17 AC 117 ms
54,168 KB
testcase_18 AC 104 ms
54,032 KB
testcase_19 AC 115 ms
53,956 KB
testcase_20 AC 116 ms
54,284 KB
testcase_21 AC 113 ms
53,960 KB
testcase_22 AC 107 ms
53,084 KB
testcase_23 AC 106 ms
52,780 KB
testcase_24 AC 105 ms
52,812 KB
testcase_25 AC 117 ms
54,104 KB
testcase_26 AC 110 ms
53,460 KB
testcase_27 AC 108 ms
52,932 KB
testcase_28 AC 105 ms
52,980 KB
testcase_29 AC 106 ms
53,004 KB
testcase_30 AC 117 ms
54,368 KB
testcase_31 AC 109 ms
52,892 KB
testcase_32 AC 113 ms
53,992 KB
testcase_33 AC 120 ms
53,936 KB
testcase_34 AC 117 ms
53,972 KB
権限があれば一括ダウンロードができます

ソースコード

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