結果

問題 No.800 四平方定理
ユーザー edamame882edamame882
提出日時 2019-08-03 22:57:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 69 ms / 2,000 ms
コード長 1,106 bytes
コンパイル時間 1,702 ms
コンパイル使用メモリ 163,256 KB
実行使用メモリ 36,260 KB
最終ジャッジ日時 2023-09-20 17:07:35
合計ジャッジ時間 3,882 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,476 KB
testcase_01 AC 2 ms
5,592 KB
testcase_02 AC 2 ms
5,476 KB
testcase_03 AC 2 ms
5,420 KB
testcase_04 AC 2 ms
5,592 KB
testcase_05 AC 3 ms
5,420 KB
testcase_06 AC 2 ms
5,384 KB
testcase_07 AC 2 ms
5,452 KB
testcase_08 AC 2 ms
5,452 KB
testcase_09 AC 2 ms
5,468 KB
testcase_10 AC 21 ms
19,760 KB
testcase_11 AC 25 ms
21,928 KB
testcase_12 AC 25 ms
21,992 KB
testcase_13 AC 22 ms
19,792 KB
testcase_14 AC 25 ms
21,856 KB
testcase_15 AC 25 ms
21,844 KB
testcase_16 AC 25 ms
21,904 KB
testcase_17 AC 24 ms
21,972 KB
testcase_18 AC 27 ms
21,816 KB
testcase_19 AC 27 ms
21,840 KB
testcase_20 AC 2 ms
5,536 KB
testcase_21 AC 2 ms
5,416 KB
testcase_22 AC 27 ms
21,756 KB
testcase_23 AC 65 ms
36,260 KB
testcase_24 AC 61 ms
34,148 KB
testcase_25 AC 64 ms
33,908 KB
testcase_26 AC 2 ms
4,992 KB
testcase_27 AC 2 ms
5,000 KB
testcase_28 AC 60 ms
33,932 KB
testcase_29 AC 62 ms
34,196 KB
testcase_30 AC 60 ms
33,964 KB
testcase_31 AC 54 ms
32,024 KB
testcase_32 AC 69 ms
34,148 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

  int mp[(int)2e7];
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,d;
  cin >> n >> d;

  int  ans = 0;
  FOR(a,1,n+1) FOR(b,1,n+1) mp[a*a + b*b + (int)1e7] ++;
  FOR(w,1,n+1) FOR(c,1,n+1) ans += mp[d + w*w - c*c + (int)1e7];
  cout << ans << endl;
  return 0;
}
0