結果

問題 No.800 四平方定理
ユーザー akakimidoriakakimidori
提出日時 2019-03-17 21:25:31
言語 C
(gcc 11.2.0)
結果
AC  
実行時間 50 ms / 2,000 ms
コード長 469 bytes
コンパイル時間 103 ms
使用メモリ 32,560 KB
最終ジャッジ日時 2023-02-11 03:43:15
合計ジャッジ時間 1,973 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 1 ms
4,900 KB
testcase_01 AC 1 ms
5,160 KB
testcase_02 AC 1 ms
4,904 KB
testcase_03 AC 1 ms
4,904 KB
testcase_04 AC 1 ms
5,156 KB
testcase_05 AC 1 ms
4,900 KB
testcase_06 AC 1 ms
4,900 KB
testcase_07 AC 1 ms
4,904 KB
testcase_08 AC 1 ms
5,156 KB
testcase_09 AC 1 ms
5,152 KB
testcase_10 AC 13 ms
17,000 KB
testcase_11 AC 16 ms
18,876 KB
testcase_12 AC 13 ms
18,728 KB
testcase_13 AC 13 ms
17,724 KB
testcase_14 AC 15 ms
18,932 KB
testcase_15 AC 14 ms
18,908 KB
testcase_16 AC 12 ms
19,140 KB
testcase_17 AC 14 ms
19,064 KB
testcase_18 AC 15 ms
19,048 KB
testcase_19 AC 14 ms
19,068 KB
testcase_20 AC 1 ms
4,904 KB
testcase_21 AC 1 ms
5,156 KB
testcase_22 AC 18 ms
19,064 KB
testcase_23 AC 42 ms
32,520 KB
testcase_24 AC 42 ms
32,552 KB
testcase_25 AC 38 ms
32,380 KB
testcase_26 AC 0 ms
5,164 KB
testcase_27 AC 0 ms
5,256 KB
testcase_28 AC 34 ms
32,368 KB
testcase_29 AC 35 ms
32,560 KB
testcase_30 AC 36 ms
32,376 KB
testcase_31 AC 30 ms
30,288 KB
testcase_32 AC 50 ms
32,524 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

typedef long long int int64;

void run(void){
  int n,d;
  scanf("%d%d",&n,&d);
  int len=2*n*n;
  int *dp=(int *)calloc(len+1,sizeof(int));
  int i,j;
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      dp[i*i+j*j]++;
    }
  }
  int64 ans=0;
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      int v=d+j*j-i*i;
      if(0<=v && v<=len){
	ans+=dp[v];
      }
    }
  }
  printf("%lld\n",ans);
}

int main(void){
  run();
  return 0;
}
0