結果

問題 No.800 四平方定理
ユーザー cotton_fn_cotton_fn_
提出日時 2019-06-30 18:56:23
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,254 bytes
コンパイル時間 1,514 ms
コンパイル使用メモリ 110,880 KB
実行使用メモリ 127,964 KB
最終ジャッジ日時 2023-09-20 17:18:47
合計ジャッジ時間 4,507 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,412 KB
testcase_01 AC 4 ms
5,432 KB
testcase_02 AC 3 ms
4,540 KB
testcase_03 AC 3 ms
5,000 KB
testcase_04 AC 3 ms
4,720 KB
testcase_05 AC 3 ms
4,808 KB
testcase_06 AC 5 ms
6,076 KB
testcase_07 RE -
testcase_08 RE -
testcase_09 AC 5 ms
5,328 KB
testcase_10 AC 66 ms
65,068 KB
testcase_11 AC 67 ms
72,632 KB
testcase_12 AC 69 ms
71,476 KB
testcase_13 AC 56 ms
67,800 KB
testcase_14 AC 66 ms
72,684 KB
testcase_15 AC 68 ms
72,244 KB
testcase_16 AC 62 ms
73,516 KB
testcase_17 AC 63 ms
73,384 KB
testcase_18 AC 72 ms
73,152 KB
testcase_19 AC 74 ms
73,184 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 75 ms
73,496 KB
testcase_23 AC 137 ms
127,828 KB
testcase_24 AC 121 ms
127,908 KB
testcase_25 AC 142 ms
127,628 KB
testcase_26 WA -
testcase_27 RE -
testcase_28 AC 126 ms
127,480 KB
testcase_29 AC 136 ms
127,652 KB
testcase_30 AC 124 ms
127,364 KB
testcase_31 AC 117 ms
118,768 KB
testcase_32 AC 127 ms
127,964 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;
  vector<i64> a(2 * n * n + 1), b(2 * n * n + 1);
  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 (z > 0) b[z]++;
    }
  }
  i64 ans = 0;
  for (i64 i = 1; i <= a.size(); ++i) {
    ans += a[i] * b[i];
  }
  cout << ans << '\n';
  return 0;
}
0