結果

問題 No.781 円周上の格子点の数え上げ
ユーザー hirohiro
提出日時 2019-01-20 22:29:09
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 998 bytes
コンパイル時間 6,237 ms
コンパイル使用メモリ 83,844 KB
実行使用メモリ 39,632 KB
最終ジャッジ日時 2023-10-12 02:52:00
合計ジャッジ時間 10,923 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
39,632 KB
testcase_01 AC 52 ms
34,584 KB
testcase_02 AC 52 ms
34,640 KB
testcase_03 AC 51 ms
34,800 KB
testcase_04 AC 54 ms
35,000 KB
testcase_05 AC 52 ms
35,152 KB
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

package ycoder;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class CircleLatticePoint {
	public static void main(String... string) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] tmp = br.readLine().split(" ");
		
		int rMin = Integer.parseInt(tmp[0]);
		int rMax = Integer.parseInt(tmp[1]);
		ArrayList<Integer> latticePointList = new ArrayList<>();

		CircleLatticePoint clp = new CircleLatticePoint();
		for(int r = rMin; r <= rMax; r++) {
			latticePointList.add(clp.getLatticePoint(r));
		}
		latticePointList.stream()
						.sorted((a,b) -> b - a);
		int maxLatticePoint = latticePointList.get(0);
		System.out.println(maxLatticePoint);
	}
	public int getLatticePoint(int r) {
		int result = 0;
		for(int x = -1 * r; x <= r; x++) {
			for(int y = -1 * r; y <= r; y++) {
				if(r == x*x + y*y) {
					result++;
				}
			}
		}
		return result;
	}
}
0