Official
A - Century Editorial by en_translator
The year \(N\) is in the \(\lfloor \frac{N+99}{100} \rfloor\)-th century (where \(\lfloor x \rfloor\) denotes \(x\) rounded down), so output this.
Sample code in Python:
import math
n = int(input())
print(math.floor((n+99)/100))
Alternatively, we can see the following fact:
“The year \(N\) is in the \(X\) century if and only if one can pay \(N\) cents with (at least) \(X\) one-dollar coins.”
Therefore, it is possible to implement by splitting into cases depending on whether \(N\) is a multiple of \(100\) or not.
Sample code in Java:
import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
int n=scanner.nextInt();
if(n%100==0){System.out.println(n/100);}
else{System.out.println((n/100)+1);}
}
}
posted:
last update: