結果

問題 No.781 円周上の格子点の数え上げ
ユーザー GrenacheGrenache
提出日時 2019-04-28 12:14:51
言語 Java21
(openjdk 21)
結果
AC  
実行時間 330 ms / 2,000 ms
コード長 915 bytes
コンパイル時間 3,590 ms
コンパイル使用メモリ 75,088 KB
実行使用メモリ 97,328 KB
最終ジャッジ日時 2023-08-22 04:00:35
合計ジャッジ時間 9,022 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
55,824 KB
testcase_01 AC 125 ms
55,360 KB
testcase_02 AC 124 ms
55,968 KB
testcase_03 AC 123 ms
55,440 KB
testcase_04 AC 125 ms
55,440 KB
testcase_05 AC 126 ms
55,820 KB
testcase_06 AC 131 ms
55,420 KB
testcase_07 AC 137 ms
55,400 KB
testcase_08 AC 307 ms
97,300 KB
testcase_09 AC 314 ms
96,816 KB
testcase_10 AC 132 ms
55,492 KB
testcase_11 AC 138 ms
55,744 KB
testcase_12 AC 323 ms
97,100 KB
testcase_13 AC 330 ms
97,328 KB
testcase_14 AC 151 ms
57,812 KB
testcase_15 AC 129 ms
55,944 KB
testcase_16 AC 130 ms
55,324 KB
testcase_17 AC 258 ms
81,900 KB
testcase_18 AC 249 ms
81,424 KB
testcase_19 AC 242 ms
83,372 KB
testcase_20 AC 247 ms
83,452 KB
権限があれば一括ダウンロードができます

ソースコード

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