結果

問題 No.800 四平方定理
ユーザー cotton_fn_cotton_fn_
提出日時 2019-06-30 19:03:19
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,258 bytes
コンパイル時間 1,088 ms
コンパイル使用メモリ 112,076 KB
実行使用メモリ 128,168 KB
最終ジャッジ日時 2023-09-20 17:28:46
合計ジャッジ時間 4,144 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,440 KB
testcase_01 AC 4 ms
5,292 KB
testcase_02 AC 3 ms
4,636 KB
testcase_03 AC 4 ms
4,768 KB
testcase_04 AC 3 ms
4,492 KB
testcase_05 AC 3 ms
4,912 KB
testcase_06 AC 4 ms
5,900 KB
testcase_07 AC 3 ms
5,116 KB
testcase_08 AC 4 ms
5,860 KB
testcase_09 AC 4 ms
5,600 KB
testcase_10 AC 62 ms
64,788 KB
testcase_11 AC 67 ms
72,616 KB
testcase_12 AC 69 ms
71,372 KB
testcase_13 AC 61 ms
67,856 KB
testcase_14 AC 64 ms
72,632 KB
testcase_15 AC 70 ms
72,048 KB
testcase_16 AC 64 ms
73,412 KB
testcase_17 AC 62 ms
73,424 KB
testcase_18 AC 73 ms
72,808 KB
testcase_19 AC 75 ms
73,072 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 74 ms
73,424 KB
testcase_23 AC 143 ms
127,996 KB
testcase_24 AC 126 ms
128,168 KB
testcase_25 AC 142 ms
127,640 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 127 ms
127,500 KB
testcase_29 AC 140 ms
127,752 KB
testcase_30 AC 126 ms
127,480 KB
testcase_31 AC 112 ms
118,908 KB
testcase_32 AC 127 ms
128,004 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n, d;
int main() {
  cin >> n >> d;
  i64 m = 2 * n * n + 1;
  vector<i64> a(m), b(m);
  for (i64 x = 1; x <= n; ++x) {
    for (i64 y = 1; y <= n; ++y) {
      a[x * x + y * y]++;
      i64 z = x * x - y * y + d;
      if (0 < z && z <= m) b[z]++;
    }
  }
  i64 ans = 0;
  for (i64 i = 1; i <= m; ++i) {
    ans += a[i] * b[i];
  }
  cout << ans << '\n';
  return 0;
}
0