結果

問題 No.800 四平方定理
ユーザー 37zigen37zigen
提出日時 2019-03-17 21:58:04
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 504 bytes
コンパイル時間 1,162 ms
コンパイル使用メモリ 151,472 KB
実行使用メモリ 43,876 KB
最終ジャッジ日時 2023-09-22 05:52:18
合計ジャッジ時間 18,097 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
8,756 KB
testcase_01 AC 28 ms
4,908 KB
testcase_02 AC 20 ms
4,424 KB
testcase_03 AC 21 ms
4,572 KB
testcase_04 AC 19 ms
4,624 KB
testcase_05 AC 22 ms
4,836 KB
testcase_06 AC 32 ms
5,200 KB
testcase_07 AC 26 ms
4,776 KB
testcase_08 AC 27 ms
5,160 KB
testcase_09 AC 29 ms
4,960 KB
testcase_10 TLE -
testcase_11 TLE -
testcase_12 TLE -
testcase_13 AC 1,723 ms
41,196 KB
testcase_14 AC 1,960 ms
43,876 KB
testcase_15 TLE -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,564 KB
testcase_22 TLE -
testcase_23 TLE -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

int main(){
  
  int N;
  long long D;
  std::cin>>N>>D;

  std::map<long long, int> mp1;

  for(long long x=1;x<=N;++x){
    for(long long y=1;y<=N;++y){
      if(mp1.find(x*x+y*y)==mp1.end()){
	mp1[x*x+y*y]=1;
      }else{
	++mp1[x*x+y*y];
      }
    }
  }
  
  long long ans=0;
  for(long long z=1;z<=N;++z){
    for(long long w=1;w<=N;++w){
      if(mp1.find(w*w+D-z*z)!=mp1.end()){
	ans +=mp1[w*w+D-z*z];
      }
    }
  }
  
  std::cout<<ans<<std::endl;

  return 0;
}


0