結果

問題 No.800 四平方定理
ユーザー emthrmemthrm
提出日時 2019-03-17 21:25:46
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,455 ms / 2,000 ms
コード長 1,125 bytes
コンパイル時間 1,335 ms
コンパイル使用メモリ 125,800 KB
実行使用メモリ 21,032 KB
最終ジャッジ日時 2023-09-22 03:31:44
合計ジャッジ時間 22,016 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
4,376 KB
testcase_01 AC 19 ms
4,376 KB
testcase_02 AC 14 ms
4,376 KB
testcase_03 AC 14 ms
4,376 KB
testcase_04 AC 13 ms
4,376 KB
testcase_05 AC 15 ms
4,376 KB
testcase_06 AC 22 ms
4,380 KB
testcase_07 AC 14 ms
4,376 KB
testcase_08 AC 9 ms
4,376 KB
testcase_09 AC 18 ms
4,376 KB
testcase_10 AC 641 ms
12,144 KB
testcase_11 AC 700 ms
19,628 KB
testcase_12 AC 734 ms
20,332 KB
testcase_13 AC 577 ms
11,968 KB
testcase_14 AC 638 ms
19,656 KB
testcase_15 AC 727 ms
20,616 KB
testcase_16 AC 642 ms
20,268 KB
testcase_17 AC 644 ms
19,572 KB
testcase_18 AC 817 ms
19,996 KB
testcase_19 AC 804 ms
20,496 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 824 ms
20,436 KB
testcase_23 AC 1,455 ms
19,672 KB
testcase_24 AC 1,213 ms
20,312 KB
testcase_25 AC 1,434 ms
21,032 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 1,264 ms
19,928 KB
testcase_29 AC 1,421 ms
20,572 KB
testcase_30 AC 1,214 ms
20,520 KB
testcase_31 AC 1,123 ms
19,756 KB
testcase_32 AC 1,312 ms
20,908 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f, MOD = 1000000007;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*-----------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, d; cin >> n >> d;
  vector<int> rhs;
  FOR(w, 1, n + 1) FOR(z, 1, n + 1) {
    rhs.emplace_back(d + w * w - z * z);
  }
  sort(ALL(rhs));
  long long ans = 0;
  FOR(x, 1, n + 1) FOR(y, 1, n + 1) {
    int lhs = x * x + y * y;
    ans += upper_bound(ALL(rhs), lhs) - lower_bound(ALL(rhs), lhs);
  }
  cout << ans << '\n';
  return 0;
}
0