結果
| 問題 |
No.800 四平方定理
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-03-17 22:43:54 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 44 ms / 2,000 ms |
| コード長 | 556 bytes |
| コンパイル時間 | 4,452 ms |
| コンパイル使用メモリ | 191,380 KB |
| 最終ジャッジ日時 | 2025-01-06 23:10:27 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
int cnt[8000000] = {};
signed main() {
ios::sync_with_stdio(false); cin.tie(0);
int n, d;
cin >> n >> d;
for (int w = 1; w <= n; w++) {
for (int z = 1; z <= n; z++) {
if (d + w * w - z * z < 0) continue;
if (d + w * w - z * z > 2 * n * n) continue;
cnt[d + w * w - z * z]++;
}
}
long long ans = 0;
for (int x = 1; x <= n; x++) {
for (int y = 1; y <= n; y++) {
ans += cnt[x * x + y * y];
}
}
cout << ans << endl;
return 0;
}