結果

問題 No.524 コインゲーム
ユーザー Shun_PIShun_PI
提出日時 2017-06-02 23:48:22
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 2,089 bytes
コンパイル時間 4,078 ms
コンパイル使用メモリ 77,284 KB
実行使用メモリ 53,392 KB
最終ジャッジ日時 2023-10-22 01:54:46
合計ジャッジ時間 5,846 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
53,068 KB
testcase_01 AC 54 ms
53,060 KB
testcase_02 AC 54 ms
53,060 KB
testcase_03 AC 54 ms
53,068 KB
testcase_04 RE -
testcase_05 AC 54 ms
53,060 KB
testcase_06 AC 53 ms
53,052 KB
testcase_07 AC 54 ms
53,060 KB
testcase_08 AC 54 ms
53,068 KB
testcase_09 AC 54 ms
53,068 KB
testcase_10 AC 54 ms
53,060 KB
testcase_11 AC 55 ms
53,060 KB
testcase_12 AC 55 ms
53,056 KB
testcase_13 AC 54 ms
53,056 KB
testcase_14 AC 53 ms
53,056 KB
testcase_15 AC 54 ms
51,956 KB
testcase_16 AC 53 ms
53,056 KB
testcase_17 AC 53 ms
53,060 KB
testcase_18 AC 54 ms
53,056 KB
testcase_19 AC 54 ms
53,068 KB
testcase_20 AC 54 ms
53,052 KB
testcase_21 AC 55 ms
53,060 KB
testcase_22 AC 56 ms
53,056 KB
testcase_23 AC 55 ms
53,052 KB
testcase_24 AC 54 ms
53,056 KB
testcase_25 AC 54 ms
53,052 KB
testcase_26 RE -
testcase_27 RE -
testcase_28 AC 53 ms
53,068 KB
testcase_29 AC 53 ms
53,064 KB
testcase_30 AC 54 ms
53,068 KB
testcase_31 AC 53 ms
53,052 KB
testcase_32 AC 54 ms
53,072 KB
testcase_33 AC 54 ms
53,004 KB
testcase_34 AC 54 ms
53,052 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	static FastScanner sc = new FastScanner();

	public static void main(String[] args) {
		long N = sc.nextInt();
		
		
		long i = 1;
		while(i <= N) {
			long cnt = 0;
			cnt += (N+1) / (i*2) * i;
			cnt += Math.max((N+1) % (i*2) - i, 0);
			if(cnt%2 == 1) {
				System.out.println("O");
				return;
			}
			i *= 2;
		}
		
		System.out.println("X");
	}

	static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if(ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch(IOException e) {
                    e.printStackTrace();
                }
                if(buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }
}
0