結果

問題 No.800 四平方定理
ユーザー 37zigen37zigen
提出日時 2019-03-17 22:20:12
言語 C++11
(gcc 8.5.0)
結果
AC  
実行時間 55 ms / 2,000 ms
コード長 423 bytes
コンパイル時間 1,000 ms
使用メモリ 34,784 KB
最終ジャッジ日時 2023-02-11 08:28:36
合計ジャッジ時間 3,408 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 15 ms
34,728 KB
testcase_01 AC 15 ms
34,688 KB
testcase_02 AC 15 ms
34,736 KB
testcase_03 AC 15 ms
34,620 KB
testcase_04 AC 17 ms
34,748 KB
testcase_05 AC 16 ms
34,728 KB
testcase_06 AC 16 ms
34,628 KB
testcase_07 AC 16 ms
34,784 KB
testcase_08 AC 17 ms
34,724 KB
testcase_09 AC 16 ms
34,676 KB
testcase_10 AC 27 ms
34,688 KB
testcase_11 AC 28 ms
34,684 KB
testcase_12 AC 27 ms
34,744 KB
testcase_13 AC 28 ms
34,732 KB
testcase_14 AC 27 ms
34,748 KB
testcase_15 AC 27 ms
34,620 KB
testcase_16 AC 29 ms
34,696 KB
testcase_17 AC 31 ms
34,628 KB
testcase_18 AC 32 ms
34,620 KB
testcase_19 AC 29 ms
34,768 KB
testcase_20 AC 17 ms
34,684 KB
testcase_21 AC 16 ms
34,624 KB
testcase_22 AC 29 ms
34,688 KB
testcase_23 AC 52 ms
34,684 KB
testcase_24 AC 49 ms
34,620 KB
testcase_25 AC 53 ms
34,768 KB
testcase_26 AC 17 ms
34,728 KB
testcase_27 AC 16 ms
34,696 KB
testcase_28 AC 49 ms
34,732 KB
testcase_29 AC 52 ms
34,724 KB
testcase_30 AC 49 ms
34,748 KB
testcase_31 AC 47 ms
34,744 KB
testcase_32 AC 55 ms
34,688 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