結果

問題 No.781 円周上の格子点の数え上げ
ユーザー neko_the_shadowneko_the_shadow
提出日時 2019-02-06 21:03:45
言語 Java21
(openjdk 21)
結果
AC  
実行時間 287 ms / 2,000 ms
コード長 664 bytes
コンパイル時間 4,046 ms
コンパイル使用メモリ 76,088 KB
実行使用メモリ 97,884 KB
最終ジャッジ日時 2023-09-05 03:24:40
合計ジャッジ時間 9,123 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
55,552 KB
testcase_01 AC 128 ms
55,736 KB
testcase_02 AC 127 ms
55,584 KB
testcase_03 AC 129 ms
55,668 KB
testcase_04 AC 128 ms
55,544 KB
testcase_05 AC 129 ms
55,868 KB
testcase_06 AC 128 ms
55,680 KB
testcase_07 AC 133 ms
55,700 KB
testcase_08 AC 272 ms
97,884 KB
testcase_09 AC 270 ms
97,848 KB
testcase_10 AC 132 ms
55,940 KB
testcase_11 AC 133 ms
55,392 KB
testcase_12 AC 287 ms
97,748 KB
testcase_13 AC 287 ms
97,508 KB
testcase_14 AC 150 ms
57,356 KB
testcase_15 AC 132 ms
55,688 KB
testcase_16 AC 130 ms
55,560 KB
testcase_17 AC 228 ms
81,152 KB
testcase_18 AC 209 ms
80,912 KB
testcase_19 AC 217 ms
81,160 KB
testcase_20 AC 219 ms
81,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner stdin = new Scanner(System.in);
        int X = stdin.nextInt();
        int Y = stdin.nextInt();
        
        int[] counts = new int[Y + 1];
        for (int x = 1; x * x <= Y; x++) {
            for (int y = 0; y * y <= Y; y++) {
                int z = x * x + y * y;
                if (z <= Y) {
                    counts[z] += 1;
                }
            }
        }
        
        int ans = IntStream.rangeClosed(X, Y).map(i -> counts[i]).max().getAsInt();
        System.out.println(ans * 4);
    }
}
0