結果

問題 No.781 円周上の格子点の数え上げ
コンテスト
ユーザー hiro
提出日時 2019-01-22 00:33:32
言語 Java
(openjdk 25.0.2)
コンパイル:
javac -encoding UTF8 _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true _class_
結果
TLE  
実行時間 -
コード長 977 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,626 ms
コンパイル使用メモリ 81,660 KB
実行使用メモリ 39,896 KB
最終ジャッジ日時 2026-04-04 20:06:29
合計ジャッジ時間 8,255 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 12 TLE * 1 -- * 8
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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