Official
		
			
				A - Century Editorial
			
			by 
		
		
		
			
		
		
			
	
			
				A - Century Editorial
			
			by  physics0523
physics0523
			
		
		
		西暦 \(N\) 年は \(\lfloor \frac{N+99}{100} \rfloor\) 世紀(ただし、\(\lfloor x \rfloor\) で \(x\) の小数点以下切り捨て) なので、これを出力すればよいです。
Pythonによる実装例:
import math
n = int(input())
print(math.floor((n+99)/100))
他にも、以下のような言い回しがあります。
「\(N\) 円が(最小で) \(100\) 円玉 \(X\) 枚で払えるとき、西暦 \(N\) 年は \(X\) 世紀」
これをもとに、 \(N\) が \(100\) の倍数のときだけ場合分けして実装することも可能です。
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:
				
			
