結果

問題 No.800 四平方定理
ユーザー Artemis2718Artemis2718
提出日時 2019-04-27 11:23:49
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 91 ms / 2,000 ms
コード長 641 bytes
コンパイル時間 487 ms
コンパイル使用メモリ 29,472 KB
実行使用メモリ 52,440 KB
最終ジャッジ日時 2023-08-18 08:23:39
合計ジャッジ時間 2,920 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
4,376 KB
testcase_01 AC 7 ms
4,376 KB
testcase_02 AC 6 ms
4,380 KB
testcase_03 AC 7 ms
4,380 KB
testcase_04 AC 6 ms
4,376 KB
testcase_05 AC 6 ms
4,376 KB
testcase_06 AC 7 ms
4,476 KB
testcase_07 AC 7 ms
4,376 KB
testcase_08 AC 7 ms
4,380 KB
testcase_09 AC 6 ms
4,380 KB
testcase_10 AC 32 ms
27,620 KB
testcase_11 AC 34 ms
29,828 KB
testcase_12 AC 36 ms
30,416 KB
testcase_13 AC 32 ms
27,560 KB
testcase_14 AC 37 ms
30,296 KB
testcase_15 AC 37 ms
31,372 KB
testcase_16 AC 34 ms
29,736 KB
testcase_17 AC 37 ms
29,020 KB
testcase_18 AC 38 ms
33,148 KB
testcase_19 AC 39 ms
33,524 KB
testcase_20 AC 6 ms
4,380 KB
testcase_21 AC 5 ms
4,376 KB
testcase_22 AC 40 ms
34,340 KB
testcase_23 AC 89 ms
52,044 KB
testcase_24 AC 79 ms
48,184 KB
testcase_25 AC 91 ms
52,440 KB
testcase_26 AC 6 ms
4,376 KB
testcase_27 AC 6 ms
4,376 KB
testcase_28 AC 84 ms
47,772 KB
testcase_29 AC 84 ms
50,236 KB
testcase_30 AC 77 ms
48,776 KB
testcase_31 AC 68 ms
45,992 KB
testcase_32 AC 79 ms
48,816 KB
権限があれば一括ダウンロードができます

ソースコード

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)*8000000);
    cnt2 = (int *)malloc(sizeof(int)*8000000);
    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<=8000000;k++){
        ans += cnt1[k]*cnt2[k];
    }
    printf("%d\n",ans);
    free(cnt1);
    free(cnt2);
    return 0;
}
0