結果
問題 | No.800 四平方定理 |
ユーザー |
![]() |
提出日時 | 2019-04-07 01:37:38 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,557 ms / 2,000 ms |
コード長 | 1,240 bytes |
コンパイル時間 | 2,211 ms |
コンパイル使用メモリ | 173,852 KB |
実行使用メモリ | 37,660 KB |
最終ジャッジ日時 | 2024-06-25 12:30:42 |
合計ジャッジ時間 | 22,521 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define llong long long int #define ldouble long double #define rep(i, n) for (int i = 0; i < n; ++i) #define REP(i, k, n) for (int i = k; i < n; ++i) #define fore(i,a) for (auto &i : a) #define repr(i, n) for (int i = n; i >= 0; --i) #define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr) #define all(x) x.begin(), x.end() #define allr(x) x.rbegin(), x.rend() const static int mod = 1000000000 + 7; const static int inf = INT_MAX / 2; const static llong INF = LLONG_MAX / 2; const static double eps = 1e-10; const static int dx[] = {1, 0, -1, 0}; const static int dy[] = {0, 1, 0, -1}; signed main (int argc, char *argv[]) { cin.tie(0); ios::sync_with_stdio(false); llong n, d; cin >> n >> d; vector<llong> XY; for (llong x = 1; x <= n; ++x) { for (llong y = 1; y <= n; ++y) { XY.push_back(x * x + y * y); } } sort(all(XY)); llong res = 0; for (llong z = 1; z <= n; ++z) { for (llong w = 1; w <= n; ++w) { llong target = w * w - z * z + d; res += upper_bound(all(XY), target) - lower_bound(all(XY), target); } } cout << res << endl; return 0; }