結果

問題 No.800 四平方定理
ユーザー 👑 emthrmemthrm
提出日時 2019-03-17 21:25:46
言語 C++17
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 1,351 ms / 2,000 ms
コード長 1,125 bytes
コンパイル時間 1,576 ms
使用メモリ 19,688 KB
最終ジャッジ日時 2023-02-11 03:48:46
合計ジャッジ時間 20,039 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 10 ms
4,904 KB
testcase_01 AC 18 ms
5,156 KB
testcase_02 AC 13 ms
4,900 KB
testcase_03 AC 14 ms
4,904 KB
testcase_04 AC 13 ms
4,900 KB
testcase_05 AC 15 ms
4,904 KB
testcase_06 AC 21 ms
5,156 KB
testcase_07 AC 14 ms
5,156 KB
testcase_08 AC 9 ms
5,156 KB
testcase_09 AC 19 ms
4,900 KB
testcase_10 AC 630 ms
11,416 KB
testcase_11 AC 674 ms
19,668 KB
testcase_12 AC 706 ms
19,568 KB
testcase_13 AC 581 ms
11,340 KB
testcase_14 AC 634 ms
19,580 KB
testcase_15 AC 713 ms
19,596 KB
testcase_16 AC 639 ms
19,588 KB
testcase_17 AC 634 ms
19,536 KB
testcase_18 AC 758 ms
19,644 KB
testcase_19 AC 760 ms
19,460 KB
testcase_20 AC 1 ms
4,900 KB
testcase_21 AC 1 ms
4,900 KB
testcase_22 AC 766 ms
19,592 KB
testcase_23 AC 1,347 ms
19,592 KB
testcase_24 AC 1,183 ms
19,536 KB
testcase_25 AC 1,351 ms
19,464 KB
testcase_26 AC 2 ms
5,156 KB
testcase_27 AC 2 ms
4,900 KB
testcase_28 AC 1,174 ms
19,680 KB
testcase_29 AC 1,266 ms
19,548 KB
testcase_30 AC 1,172 ms
19,536 KB
testcase_31 AC 1,075 ms
19,672 KB
testcase_32 AC 1,198 ms
19,688 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