結果

問題 No.781 円周上の格子点の数え上げ
ユーザー GrenacheGrenache
提出日時 2019-04-28 12:14:51
言語 Java21
(openjdk 21)
結果
AC  
実行時間 407 ms / 2,000 ms
コード長 915 bytes
コンパイル時間 3,952 ms
コンパイル使用メモリ 79,220 KB
実行使用メモリ 83,108 KB
最終ジャッジ日時 2024-05-09 09:54:32
合計ジャッジ時間 9,753 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
40,368 KB
testcase_01 AC 134 ms
41,588 KB
testcase_02 AC 135 ms
41,508 KB
testcase_03 AC 137 ms
41,316 KB
testcase_04 AC 135 ms
41,364 KB
testcase_05 AC 140 ms
41,908 KB
testcase_06 AC 144 ms
42,044 KB
testcase_07 AC 152 ms
42,176 KB
testcase_08 AC 399 ms
82,880 KB
testcase_09 AC 391 ms
82,684 KB
testcase_10 AC 142 ms
41,768 KB
testcase_11 AC 145 ms
42,016 KB
testcase_12 AC 402 ms
83,108 KB
testcase_13 AC 407 ms
82,912 KB
testcase_14 AC 168 ms
44,020 KB
testcase_15 AC 141 ms
41,576 KB
testcase_16 AC 146 ms
41,756 KB
testcase_17 AC 307 ms
66,704 KB
testcase_18 AC 292 ms
67,024 KB
testcase_19 AC 303 ms
67,828 KB
testcase_20 AC 293 ms
67,232 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