結果
| 問題 |
No.800 四平方定理
|
| コンテスト | |
| ユーザー |
yumarimo
|
| 提出日時 | 2019-04-07 01:34:15 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,165 bytes |
| コンパイル時間 | 1,569 ms |
| コンパイル使用メモリ | 174,124 KB |
| 実行使用メモリ | 34,464 KB |
| 最終ジャッジ日時 | 2024-06-25 12:29:50 |
| 合計ジャッジ時間 | 18,649 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 2 |
| other | AC * 1 WA * 29 |
ソースコード
#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(n * n);
rep(x, n) {
rep(y, n) {
XY[x * n + y] = x * x + y * y;
}
}
sort(all(XY));
llong res = 0;
rep(z, n) {
rep(w, n) {
llong target = w * w + d - z * z;
res += upper_bound(all(XY), target) - lower_bound(all(XY), target);
}
}
cout << res << endl;
return 0;
}
yumarimo