結果
| 問題 |
No.800 四平方定理
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-02-19 21:02:08 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 148 ms / 2,000 ms |
| コード長 | 555 bytes |
| コンパイル時間 | 3,882 ms |
| コンパイル使用メモリ | 275,300 KB |
| 実行使用メモリ | 128,340 KB |
| 最終ジャッジ日時 | 2025-02-19 21:02:17 |
| 合計ジャッジ時間 | 8,116 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, d; cin >> n >> d;
int O = 8'000'010;
vector<int> V(O*2+1, 0);
vector<int> W(O*2+1, 0);
for(int x = 1; x <= n; x++) {
for(int y = 1; y <= n; y++) {
V[x * x + y * y + O]++;
}
}
for(int z = 1; z <= n; z++) {
for(int w = 1; w <= n; w++) {
W[w * w - z * z + d + O]++;
}
}
int ans = 0;
for(int i = -O; i <= O; i++) {
ans += V[i+O] * W[i+O];
}
cout << ans << endl;
return 0;
}