結果

問題 No.524 コインゲーム
ユーザー Shun_PIShun_PI
提出日時 2017-06-02 23:50:04
言語 Java21
(openjdk 21)
結果
AC  
実行時間 51 ms / 1,000 ms
コード長 2,090 bytes
コンパイル時間 1,907 ms
コンパイル使用メモリ 77,576 KB
実行使用メモリ 50,208 KB
最終ジャッジ日時 2024-04-10 08:43:46
合計ジャッジ時間 4,710 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 51 ms
49,808 KB
testcase_01 AC 51 ms
49,768 KB
testcase_02 AC 49 ms
49,652 KB
testcase_03 AC 47 ms
50,024 KB
testcase_04 AC 47 ms
50,036 KB
testcase_05 AC 47 ms
50,132 KB
testcase_06 AC 48 ms
50,036 KB
testcase_07 AC 48 ms
49,996 KB
testcase_08 AC 49 ms
49,764 KB
testcase_09 AC 49 ms
49,712 KB
testcase_10 AC 48 ms
50,000 KB
testcase_11 AC 47 ms
49,780 KB
testcase_12 AC 48 ms
49,900 KB
testcase_13 AC 50 ms
50,048 KB
testcase_14 AC 50 ms
50,040 KB
testcase_15 AC 49 ms
49,716 KB
testcase_16 AC 48 ms
50,100 KB
testcase_17 AC 48 ms
50,000 KB
testcase_18 AC 48 ms
49,780 KB
testcase_19 AC 47 ms
49,600 KB
testcase_20 AC 47 ms
49,652 KB
testcase_21 AC 49 ms
49,716 KB
testcase_22 AC 48 ms
50,208 KB
testcase_23 AC 49 ms
49,984 KB
testcase_24 AC 50 ms
49,932 KB
testcase_25 AC 50 ms
49,808 KB
testcase_26 AC 49 ms
49,672 KB
testcase_27 AC 48 ms
49,744 KB
testcase_28 AC 50 ms
50,028 KB
testcase_29 AC 50 ms
50,076 KB
testcase_30 AC 49 ms
49,964 KB
testcase_31 AC 49 ms
49,656 KB
testcase_32 AC 49 ms
49,760 KB
testcase_33 AC 48 ms
50,160 KB
testcase_34 AC 48 ms
49,900 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.nextLong();
		
		
		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