結果

問題 No.1593 Perfect Distance
ユーザー GetDigit()GetDigit()
提出日時 2022-10-24 21:03:00
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 395 bytes
コンパイル時間 1,391 ms
コンパイル使用メモリ 164,668 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-15 22:41:22
合計ジャッジ時間 2,445 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

bool is_square(long N) {
    long r = (long)floor(sqrt((long double)N));  // 切り捨てした平方根
    return (r * r) == N;
}

int main(){
    int N;
    long tmp;
    scanf("%d",&N);
    int count = 0;
    for(int i=1;i<N;i++){
        tmp = N*N-i*i;
        if(is_square(tmp)){
            count++;
        }
    }
    printf("%d",count);
}
0