結果

問題 No.800 四平方定理
ユーザー 34056915823405691582
提出日時 2019-03-22 18:33:04
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 105 ms / 2,000 ms
コード長 606 bytes
コンパイル時間 466 ms
コンパイル使用メモリ 30,756 KB
実行使用メモリ 64,232 KB
最終ジャッジ日時 2023-10-19 06:11:47
合計ジャッジ時間 2,887 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 3 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 3 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 38 ms
32,524 KB
testcase_11 AC 44 ms
36,416 KB
testcase_12 AC 45 ms
35,888 KB
testcase_13 AC 38 ms
34,108 KB
testcase_14 AC 42 ms
36,416 KB
testcase_15 AC 44 ms
36,152 KB
testcase_16 AC 42 ms
36,876 KB
testcase_17 AC 42 ms
36,876 KB
testcase_18 AC 47 ms
36,612 KB
testcase_19 AC 46 ms
36,612 KB
testcase_20 AC 1 ms
4,348 KB
testcase_21 AC 1 ms
4,348 KB
testcase_22 AC 49 ms
36,876 KB
testcase_23 AC 103 ms
64,232 KB
testcase_24 AC 102 ms
64,188 KB
testcase_25 AC 102 ms
63,908 KB
testcase_26 AC 1 ms
4,348 KB
testcase_27 AC 1 ms
4,348 KB
testcase_28 AC 96 ms
63,840 KB
testcase_29 AC 105 ms
63,976 KB
testcase_30 AC 98 ms
63,976 KB
testcase_31 AC 88 ms
59,624 KB
testcase_32 AC 101 ms
64,104 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(void){
  int n, d, i, j;
  scanf("%d %d", &n, &d);
  int *xy, *zwd;
  xy=malloc(sizeof(int)*n*n*2);
  if(xy == NULL) exit(1);
  zwd=malloc(sizeof(int)*n*n*2);
  if(zwd == NULL) exit(1);
  for(i=0; i<n*n*2; i++) xy[i]=zwd[i]=0;
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      xy[i*i+j*j-1]++;
    }
  }
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      if(1<=i*i-j*j+d && i*i-j*j+d<=n*n*2) zwd[i*i-j*j+d-1]++;
    }
  }
  for(i=0; i<n*n*2; i++) xy[i]*=zwd[i];
  for(i=j=0; i<n*n*2; i++) j+=xy[i];
  printf("%d\n", j);
  free(xy);
  free(zwd);
  return 0;
}
0