結果

問題 No.781 円周上の格子点の数え上げ
ユーザー hirohiro
提出日時 2019-01-22 00:33:32
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 977 bytes
コンパイル時間 4,611 ms
コンパイル使用メモリ 73,688 KB
実行使用メモリ 55,204 KB
最終ジャッジ日時 2023-10-13 17:36:10
合計ジャッジ時間 10,267 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
53,552 KB
testcase_01 AC 39 ms
49,192 KB
testcase_02 AC 40 ms
49,180 KB
testcase_03 AC 41 ms
49,204 KB
testcase_04 AC 39 ms
49,264 KB
testcase_05 AC 38 ms
49,248 KB
testcase_06 AC 41 ms
49,164 KB
testcase_07 AC 44 ms
49,220 KB
testcase_08 AC 80 ms
50,732 KB
testcase_09 AC 78 ms
50,736 KB
testcase_10 AC 346 ms
50,612 KB
testcase_11 AC 1,884 ms
50,480 KB
testcase_12 TLE -
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;

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]);

		CircleLatticePoint clp = new CircleLatticePoint();
		int maxLatticePoint = 0;
		for(int r = rMin; r <= rMax; r++) {
			if(r == rMin) maxLatticePoint = clp.getLatticePoint(r);
			if(clp.getLatticePoint(r) > maxLatticePoint) {
				maxLatticePoint = clp.getLatticePoint(r);
			}
		}
		System.out.println(maxLatticePoint);
	}
	
	public int getLatticePoint(int r) {
		int result = 0;
		for(int x = 0; x <= Math.sqrt(r); x++) {
			for(int y = 0; y < Math.sqrt(r); y++) {
				if(r == x*x + y*y) {
					result++;
				}
			}
		}
		result = result * 4;
		return result;
	}
}
0