Official

A - Heavy Rotation Editorial by evima


He wears black and white in a two-day cycle, so it is sufficient to output White if the remainder of \(N\) divided by \(2\) is \(0\), and output Black if it is \(1\).

In most languages, the remainder of \(N\) by \(2\) can be calculated like N % 2, using a modulus operator %, or like N & 1, using a bitwise and operator.

Depending on the result, output Black or White using a conditional branch, and you will obtain AC.

Sample Code (C++)

#include <iostream>
using namespace std;

int main(){
    int n;
    cin >> n;
    if(n % 2 == 1) cout << "Black" << endl;
    else cout << "White" << endl;
}

Sample Code (Python)

n = int(input())
print("Black" if n % 2 == 1 else "White")

Sample Code (C)

#include <stdio.h>

int main(){
    int n;
    scanf("%d", &n);
    puts(n & 1 ? "Black" : "White");
}

Sample Code (dc)

[White][Black]?2%1=_rp

posted:
last update: