結果

問題 No.800 四平方定理
ユーザー GetDigit()GetDigit()
提出日時 2022-11-06 10:43:11
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 593 bytes
コンパイル時間 1,480 ms
コンパイル使用メモリ 164,584 KB
実行使用メモリ 7,552 KB
最終ジャッジ日時 2023-09-27 07:18:24
合計ジャッジ時間 5,962 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

//D=n^2-m^2 , 1 <= n,m <= Nを満たす組み合わせの数え上げ
int count(int d,int N){
    if(d < 0){
        d = -d;
    }
    int c = 0;
    for(int i=1;i*i<d;i++){
        if(d % i != 0) continue;
        if(i % 2 != (d/i) % 2) continue;
        if(2 <= (d/i) - d && (d/i) + d <= N){
            c++;
        }
    }
    return c;
}

int main(){
    int N,D;
    int c = 0;
    scanf("%d %d",&N,&D);
    for(int a=1;a<=N;a++){
        for(int b=1;b<=N;b++){
            c += count(D - a*a - b*b,N);
        }
    }
    printf("%d",c);
}
0