結果
| 問題 |
No.800 四平方定理
|
| コンテスト | |
| ユーザー |
neko_the_shadow
|
| 提出日時 | 2019-03-19 10:53:10 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 40 ms / 2,000 ms |
| コード長 | 569 bytes |
| コンパイル時間 | 634 ms |
| コンパイル使用メモリ | 71,960 KB |
| 最終ジャッジ日時 | 2025-01-06 23:33:41 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
#include<iostream>
#include<vector>
int main(int argc, char const *argv[]) {
// x^2 + y^2 = D+ w^2 - z^2
int n, d;
std::cin >> n >> d;
std::vector<int> c(n * n * 2 + 1, 0);
for (int x = 1; x <= n; x++) {
for (int y = 1; y <= n; y++) {
c[x * x + y * y]++;
}
}
int ans = 0;
for (int w = 1; w <= n; w++) {
for (int z = 1; z <= n; z++) {
int k = d + w * w - z * z;
if (0 <= k && k < c.size()) ans += c[k];
}
}
std::cout << ans << std::endl;
return 0;
}
neko_the_shadow