結果

問題 No.781 円周上の格子点の数え上げ
ユーザー GrenacheGrenache
提出日時 2019-04-28 12:14:51
言語 Java
(openjdk 23)
結果
AC  
実行時間 329 ms / 2,000 ms
コード長 915 bytes
コンパイル時間 3,418 ms
コンパイル使用メモリ 79,512 KB
実行使用メモリ 83,940 KB
最終ジャッジ日時 2024-12-15 21:49:10
合計ジャッジ時間 7,882 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

public class Main_yukicoder781 {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int x = sc.nextInt();
		int y = sc.nextInt();

		
		List<Integer> xx = new ArrayList<>();
		for (int i = 0; i * i <= y; i++) {
			xx.add(i * i);
		}

		int[] cnt = new int[y + 1];
		for (int i = 0; i * i < y; i++) {
			int ii = i * i;
			for (int e : xx) {
				if (ii + e > y) {
					break;
				}
				cnt[ii + e]++;
			}
		}
		
		int max = 0;
		for (int i = x; i <= y; i++) {
			max = Math.max(max, cnt[i]);
		}
		
		pr.println(max * 4);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}
0