0014-Integral
問題(外部リンク)
実装の概要
高校の教科書にも出てくる区分求積法に近いことを行う問題です。とは言っても、高さがであるような短冊型の図形の面積をひたすら足していく処理なのでプログラムにすると比較的シンプルになります。
なお、n=1でも短冊の幅が大き過ぎるため真値にはあまり近づきません。
public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); while(true){ String tmp = br.readLine(); if(tmp == null){ break; } int d = Integer.parseInt(tmp); int result = 0; for(int i = 0; i < 600; i += d){ result += d*i*i; } System.out.println(result); } } }