結果

問題 No.1593 Perfect Distance
ユーザー kinkincindykinkincindy
提出日時 2021-07-09 22:31:55
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 601 bytes
コンパイル時間 2,617 ms
コンパイル使用メモリ 75,304 KB
実行使用メモリ 61,228 KB
最終ジャッジ日時 2024-07-01 17:10:33
合計ジャッジ時間 9,621 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
46,492 KB
testcase_01 AC 129 ms
41,268 KB
testcase_02 AC 129 ms
41,232 KB
testcase_03 AC 129 ms
41,072 KB
testcase_04 AC 132 ms
40,900 KB
testcase_05 AC 136 ms
41,064 KB
testcase_06 AC 133 ms
41,164 KB
testcase_07 AC 131 ms
40,832 KB
testcase_08 AC 132 ms
40,932 KB
testcase_09 AC 189 ms
41,392 KB
testcase_10 AC 672 ms
41,116 KB
testcase_11 AC 1,490 ms
40,784 KB
testcase_12 TLE -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.lang.reflect.Array;
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = Integer.parseInt(sc.next());
        long count = 0;
        for (long y = 1; y <= n; y++){
            long xx = (n + y) * (n - y);
            if (issquared(xx)){
                count++;
            }
        }
        System.out.print(count);
    }

    private static boolean issquared(long num){
        for (int i = 1; i * i <= num; i++){
            if (i * i == num) return true;
        }
        return false;
    }
}
0