結果

問題 No.781 円周上の格子点の数え上げ
ユーザー neko_the_shadowneko_the_shadow
提出日時 2019-02-06 20:51:39
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 664 bytes
コンパイル時間 4,178 ms
コンパイル使用メモリ 78,216 KB
実行使用メモリ 98,260 KB
最終ジャッジ日時 2023-09-05 02:11:04
合計ジャッジ時間 9,175 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 130 ms
55,624 KB
testcase_02 AC 129 ms
53,840 KB
testcase_03 WA -
testcase_04 AC 129 ms
55,628 KB
testcase_05 WA -
testcase_06 AC 128 ms
56,052 KB
testcase_07 AC 134 ms
55,540 KB
testcase_08 AC 278 ms
98,260 KB
testcase_09 AC 273 ms
96,068 KB
testcase_10 AC 134 ms
56,164 KB
testcase_11 AC 138 ms
55,952 KB
testcase_12 AC 290 ms
97,548 KB
testcase_13 AC 293 ms
98,020 KB
testcase_14 AC 154 ms
57,972 KB
testcase_15 AC 132 ms
55,988 KB
testcase_16 AC 133 ms
55,544 KB
testcase_17 AC 232 ms
81,660 KB
testcase_18 AC 213 ms
81,392 KB
testcase_19 AC 219 ms
81,428 KB
testcase_20 AC 221 ms
81,688 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 = 0; 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