結果
| 問題 |
No.800 四平方定理
|
| コンテスト | |
| ユーザー |
risujiroh
|
| 提出日時 | 2019-03-17 21:28:00 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 147 ms / 2,000 ms |
| コード長 | 637 bytes |
| コンパイル時間 | 1,578 ms |
| コンパイル使用メモリ | 168,292 KB |
| 実行使用メモリ | 104,808 KB |
| 最終ジャッジ日時 | 2024-07-07 20:30:31 |
| 合計ジャッジ時間 | 4,212 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
int main() {
cin.tie(nullptr); ios::sync_with_stdio(false);
int n, d; cin >> n >> d;
V<lint> l(2 * n * n + 1);
for (int x = 1; x <= n; ++x) for (int y = 1; y <= n; ++y) {
++l[x * x + y * y];
}
V<lint> r(d + n * n);
for (int w = 1; w <= n; ++w) for (int z = 1; z <= n; ++z) {
lint t = d + w * w - z * z;
if (t >= 0) ++r[t];
}
lint res = 0;
for (int i = 0; i < min(l.size(), r.size()); ++i) {
res += l[i] * r[i];
}
cout << res << '\n';
}
risujiroh