結果

問題 No.1593 Perfect Distance
ユーザー kinkincindykinkincindy
提出日時 2021-07-09 22:32:26
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 601 bytes
コンパイル時間 2,621 ms
コンパイル使用メモリ 74,096 KB
実行使用メモリ 46,808 KB
最終ジャッジ日時 2024-07-01 17:13:52
合計ジャッジ時間 9,279 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
46,808 KB
testcase_01 AC 124 ms
41,256 KB
testcase_02 AC 122 ms
41,172 KB
testcase_03 AC 124 ms
41,096 KB
testcase_04 AC 125 ms
40,764 KB
testcase_05 AC 110 ms
40,316 KB
testcase_06 AC 123 ms
40,784 KB
testcase_07 AC 126 ms
41,308 KB
testcase_08 AC 131 ms
41,344 KB
testcase_09 AC 173 ms
40,008 KB
testcase_10 AC 664 ms
41,268 KB
testcase_11 AC 1,486 ms
40,916 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