結果

問題 No.524 コインゲーム
ユーザー GrenacheGrenache
提出日時 2017-06-02 22:56:35
言語 Java21
(openjdk 21)
結果
AC  
実行時間 125 ms / 1,000 ms
コード長 951 bytes
コンパイル時間 3,434 ms
コンパイル使用メモリ 75,436 KB
実行使用メモリ 54,556 KB
最終ジャッジ日時 2024-04-10 08:40:14
合計ジャッジ時間 8,057 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 116 ms
54,260 KB
testcase_01 AC 122 ms
54,328 KB
testcase_02 AC 125 ms
54,456 KB
testcase_03 AC 123 ms
54,020 KB
testcase_04 AC 104 ms
53,028 KB
testcase_05 AC 106 ms
53,056 KB
testcase_06 AC 107 ms
52,900 KB
testcase_07 AC 110 ms
52,840 KB
testcase_08 AC 116 ms
54,112 KB
testcase_09 AC 102 ms
52,744 KB
testcase_10 AC 113 ms
54,556 KB
testcase_11 AC 118 ms
53,876 KB
testcase_12 AC 114 ms
54,004 KB
testcase_13 AC 110 ms
53,340 KB
testcase_14 AC 119 ms
54,084 KB
testcase_15 AC 120 ms
54,380 KB
testcase_16 AC 112 ms
53,124 KB
testcase_17 AC 109 ms
53,140 KB
testcase_18 AC 120 ms
54,156 KB
testcase_19 AC 109 ms
52,960 KB
testcase_20 AC 105 ms
52,968 KB
testcase_21 AC 109 ms
52,856 KB
testcase_22 AC 113 ms
54,036 KB
testcase_23 AC 114 ms
54,288 KB
testcase_24 AC 118 ms
54,192 KB
testcase_25 AC 115 ms
54,168 KB
testcase_26 AC 112 ms
54,340 KB
testcase_27 AC 111 ms
54,072 KB
testcase_28 AC 115 ms
54,160 KB
testcase_29 AC 112 ms
54,260 KB
testcase_30 AC 105 ms
52,948 KB
testcase_31 AC 115 ms
54,112 KB
testcase_32 AC 106 ms
53,052 KB
testcase_33 AC 121 ms
54,292 KB
testcase_34 AC 124 ms
53,928 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;


public class Main_yukicoder524 {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		long n = sc.nextLong();

		long ret = 0;
		if (n < 1_000_000) {
//		if (n < 10) {
			for (int i = 1; i <= n; i++) {
				ret ^= i;
//				pr.printf("%d %d\n", i, ret);
			}
		} else {
			for (int i = 1; true; i++) {
				long tmp = (0x1L << i + 1) - 1;
				if (tmp >= n) {
					n -= (0x1L << i) - 1;
					if (n % 4 == 0) {
						ret = 0;
					} else {
						ret = 1;
					}
					break;
				}
			}
		}

		if (ret != 0) {
			pr.println("O");
		} else {
			pr.println("X");
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}
0