結果

問題 No.800 四平方定理
ユーザー 37zigen37zigen
提出日時 2019-03-17 22:20:12
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 67 ms / 2,000 ms
コード長 423 bytes
コンパイル時間 1,223 ms
コンパイル使用メモリ 143,668 KB
実行使用メモリ 34,864 KB
最終ジャッジ日時 2023-09-22 07:30:47
合計ジャッジ時間 3,261 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
34,648 KB
testcase_01 AC 12 ms
34,576 KB
testcase_02 AC 12 ms
34,576 KB
testcase_03 AC 12 ms
34,588 KB
testcase_04 AC 11 ms
34,580 KB
testcase_05 AC 12 ms
34,864 KB
testcase_06 AC 13 ms
34,632 KB
testcase_07 AC 12 ms
34,648 KB
testcase_08 AC 13 ms
34,704 KB
testcase_09 AC 12 ms
34,576 KB
testcase_10 AC 28 ms
34,784 KB
testcase_11 AC 30 ms
34,588 KB
testcase_12 AC 30 ms
34,584 KB
testcase_13 AC 28 ms
34,784 KB
testcase_14 AC 29 ms
34,672 KB
testcase_15 AC 32 ms
34,644 KB
testcase_16 AC 29 ms
34,648 KB
testcase_17 AC 29 ms
34,580 KB
testcase_18 AC 33 ms
34,784 KB
testcase_19 AC 31 ms
34,588 KB
testcase_20 AC 13 ms
34,588 KB
testcase_21 AC 13 ms
34,640 KB
testcase_22 AC 33 ms
34,632 KB
testcase_23 AC 67 ms
34,784 KB
testcase_24 AC 62 ms
34,780 KB
testcase_25 AC 67 ms
34,580 KB
testcase_26 AC 13 ms
34,708 KB
testcase_27 AC 12 ms
34,588 KB
testcase_28 AC 61 ms
34,580 KB
testcase_29 AC 64 ms
34,648 KB
testcase_30 AC 62 ms
34,584 KB
testcase_31 AC 57 ms
34,644 KB
testcase_32 AC 64 ms
34,652 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

int cnt[8000001];

int main(){
  int N;
  int D;
  std::cin>>N>>D;
  for(int i=0;i<=8000000;++i)cnt[i]=0;
  for(int x=1;x<=N;++x){
    for(int y=1;y<=N;++y){
      ++cnt[x*x+y*y];
    }
  }
  long long ans=0;
  for(int z=1;z<=N;++z){
    for(int w=1;w<=N;++w){
      if(w*w+D-z*z>8000000||w*w+D-z*z<0)continue;
      ans+=cnt[w*w+D-z*z];
    }
  }
  
  std::cout<<ans<<std::endl;

  return 0;
}


0