結果

問題 No.800 四平方定理
ユーザー yukinon0808yukinon0808
提出日時 2019-03-18 16:40:59
言語 C++11
(gcc 11.4.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,468 bytes
コンパイル時間 1,328 ms
コンパイル使用メモリ 142,612 KB
最終ジャッジ日時 2023-09-25 14:17:01
合計ジャッジ時間 2,402 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.cpp:9:64: error: ‘operator<<’ function uses ‘auto’ type specifier without trailing return type
 template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
                                                                ^
main.cpp:9:64: note: deduced return type only available with -std=c++14 or -std=gnu++14
main.cpp:10:75: error: ‘operator<<’ function uses ‘auto’ type specifier without trailing return type
 template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
                                                                           ^
main.cpp:10:75: note: deduced return type only available with -std=c++14 or -std=gnu++14
main.cpp:11:62: error: ‘operator<<’ function uses ‘auto’ type specifier without trailing return type
 template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
                                                              ^
main.cpp:11:62: note: deduced return type only available with -std=c++14 or -std=gnu++14
main.cpp:12:74: error: ‘operator<<’ function uses ‘auto’ type specifier without trailing return type
 template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
                                                                          ^
main.cpp:12:74: note: deduced return type only available with -std=c++14 or -std=gnu++14

ソースコード

diff #

#include <bits/stdc++.h>
#define int long long int
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
#define DUMP(x)  cerr<<#x<<" = "<<(x)<<endl;

struct edge { int to, cost; };

const int INF = 1e18;
const int MOD = 1e9+7;

signed main()
{
   int N, D; cin >> N >> D;

   unordered_map<int,int> cnt;
   cnt.reserve(2*N*N);
   for (int x = 1; x <= N; x++) {
      for (int y = 1; y <= N; y++) {
         cnt[x*x + y*y]++;
      }
   }

   int ans = 0;
   for (int z = 1; z <= N; z++) {
      for (int w = 1; w <= N; w++) {
         if (0 <= w*w - z*z + D && w*w - z*z + D <= 2*N*N) {
            ans += cnt[w*w - z*z + D];
         }
      }
   }
   cout << ans << endl;

   return 0;
}
0