結果

問題 No.800 四平方定理
ユーザー Artemis2718Artemis2718
提出日時 2019-04-27 11:20:33
言語 C
(gcc 12.3.0)
結果
RE  
実行時間 -
コード長 640 bytes
コンパイル時間 986 ms
コンパイル使用メモリ 29,440 KB
実行使用メモリ 33,576 KB
最終ジャッジ日時 2023-08-18 08:19:51
合計ジャッジ時間 5,818 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
4,376 KB
testcase_01 AC 4 ms
4,380 KB
testcase_02 AC 4 ms
4,376 KB
testcase_03 AC 4 ms
4,376 KB
testcase_04 AC 4 ms
4,380 KB
testcase_05 AC 5 ms
4,376 KB
testcase_06 AC 5 ms
4,380 KB
testcase_07 AC 5 ms
4,380 KB
testcase_08 AC 5 ms
4,380 KB
testcase_09 AC 5 ms
4,376 KB
testcase_10 AC 27 ms
28,648 KB
testcase_11 AC 29 ms
29,952 KB
testcase_12 AC 36 ms
30,340 KB
testcase_13 AC 27 ms
27,540 KB
testcase_14 AC 32 ms
28,308 KB
testcase_15 AC 31 ms
30,620 KB
testcase_16 AC 30 ms
28,676 KB
testcase_17 AC 28 ms
29,668 KB
testcase_18 AC 33 ms
31,876 KB
testcase_19 AC 38 ms
32,700 KB
testcase_20 AC 5 ms
4,380 KB
testcase_21 AC 4 ms
4,376 KB
testcase_22 AC 33 ms
33,576 KB
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 AC 4 ms
4,380 KB
testcase_27 AC 4 ms
4,376 KB
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    int n,d;
    int x,y,z,w;
    int k;
    int ans = 0;
    int *cnt1,*cnt2;

    cnt1 = (int *)malloc(sizeof(int)*5000000);
    cnt2 = (int *)malloc(sizeof(int)*5000000);
    scanf("%d%d",&n,&d);
    for(x=1;x<=n;x++){
        for(y=1;y<=n;y++){
            cnt1[(x*x+y*y)]++;
        }
    }
    for(z=1;z<=n;z++){
        for(w=1;w<=n;w++){
            if((w*w-z*z+d)>=0){
                cnt2[(w*w-z*z+d)]++;
            }
        }
    }
    for(k=1;k<=5000000;k++){
        ans += cnt1[k]*cnt2[k];
    }
    printf("%d\n",ans);
    free(cnt1);
    free(cnt2);
    return 0;
}
0