結果
| 問題 |
No.800 四平方定理
|
| コンテスト | |
| ユーザー |
Akidai
|
| 提出日時 | 2021-05-09 20:40:22 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 889 bytes |
| コンパイル時間 | 3,415 ms |
| コンパイル使用メモリ | 228,296 KB |
| 実行使用メモリ | 34,620 KB |
| 最終ジャッジ日時 | 2024-09-19 01:26:55 |
| 合計ジャッジ時間 | 5,308 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 WA * 2 RE * 1 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;
#define REP(i, init, n) for(int i = (int)(init); i < (int)(n); i++)
#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>
int N, D;
vi x2y2;
void solve() {
x2y2.resize(2 * N * N + 1);
REP(x, 1, N + 1) {
REP(y, 1, N + 1) {
int total = x * x + y * y;
x2y2[total]++;
}
}
long ans = 0;
REP(w, 1, N + 1) {
REP(z, 1, N + 1) {
int search = D + w * w - z * z;
if(search <= 0) continue;
ans += x2y2[search];
}
}
cout << ans << endl;
}
int main() {
cin >> N >> D;
solve();
}
Akidai