結果

問題 No.1593 Perfect Distance
ユーザー AsahiAsahi
提出日時 2023-02-04 19:35:05
言語 Java21
(openjdk 21)
結果
AC  
実行時間 141 ms / 2,000 ms
コード長 1,086 bytes
コンパイル時間 1,959 ms
コンパイル使用メモリ 76,228 KB
実行使用メモリ 55,804 KB
最終ジャッジ日時 2023-09-16 16:06:53
合計ジャッジ時間 5,540 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
55,200 KB
testcase_01 AC 128 ms
55,536 KB
testcase_02 AC 129 ms
55,396 KB
testcase_03 AC 128 ms
55,472 KB
testcase_04 AC 127 ms
53,568 KB
testcase_05 AC 126 ms
55,200 KB
testcase_06 AC 126 ms
55,472 KB
testcase_07 AC 128 ms
55,420 KB
testcase_08 AC 126 ms
55,408 KB
testcase_09 AC 130 ms
55,344 KB
testcase_10 AC 131 ms
55,256 KB
testcase_11 AC 133 ms
55,780 KB
testcase_12 AC 128 ms
55,600 KB
testcase_13 AC 128 ms
55,524 KB
testcase_14 AC 130 ms
55,804 KB
testcase_15 AC 134 ms
55,480 KB
testcase_16 AC 141 ms
55,496 KB
testcase_17 AC 126 ms
55,524 KB
testcase_18 AC 135 ms
55,392 KB
testcase_19 AC 128 ms
55,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;
import java.math.*;
import java.util.stream.Stream;

public class Main{
    /* 入出力 */
    static BufferedReader buff = new BufferedReader(new InputStreamReader(System.in));
    static StringTokenizer st;
    static PrintWriter output = new PrintWriter(System.out);
    static Scanner sc = new Scanner(System.in);
    /* 定数 */
    static final int [] y4 = {0,1,0,-1};
    static final int [] x4 = {1,0,-1,0};
    static final int  INF1 = Integer.MAX_VALUE;
    static final long INF2 = Long.MAX_VALUE;
    static final long MOD1 = (long)1e9+7;
    static final long MOD2 = 998244353;
    /* Main */
    public static void main(String[] args) throws IOException{
        long n = sc.nextLong();
        long ans = 0;
        for(long x = 1; x <= 1000000; x++) {
            long y = n*n - x*x;
            if(y <= 0 || !isInteger(Math.sqrt(y))) continue;
            ans++;
        }
        output.print(ans);
        output.flush();
    }
    static boolean isInteger (double value) {
        return (value == Math.floor(value));
    }
}
0