結果
| 問題 |
No.800 四平方定理
|
| コンテスト | |
| ユーザー |
E31415926
|
| 提出日時 | 2019-03-17 21:36:10 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 781 ms / 2,000 ms |
| コード長 | 949 bytes |
| コンパイル時間 | 769 ms |
| コンパイル使用メモリ | 98,032 KB |
| 実行使用メモリ | 65,920 KB |
| 最終ジャッジ日時 | 2024-07-07 21:00:31 |
| 合計ジャッジ時間 | 12,414 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<utility>
#include<cmath>
#include<assert.h>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<complex>
#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound
int xy[2000 * 2000];
int zw[2000 * 2000];
signed main() {
int n, d;
cin >> n >> d;
for (int x = 1; x <= n; ++x) {
for (int y = 1; y <= n; ++y) {
xy[(x - 1) * n + (y - 1)] = x * x + y * y;
zw[(x - 1) * n + (y - 1)] = x * x - y * y;
}
}
sort(xy, xy + n * n);
sort(zw, zw + n * n);
int ans = 0;
rep(i, n * n) {
ans += u_b(zw, zw + n * n, d - xy[i]) - l_b(zw, zw + n * n, d - xy[i]);
}
cout << ans << endl;
return 0;
}
E31415926