結果
| 問題 |
No.800 四平方定理
|
| コンテスト | |
| ユーザー |
ninoinui
|
| 提出日時 | 2020-07-18 10:18:48 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 146 ms / 2,000 ms |
| コード長 | 432 bytes |
| コンパイル時間 | 2,753 ms |
| コンパイル使用メモリ | 192,632 KB |
| 最終ジャッジ日時 | 2025-01-12 00:12:49 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
int N, D;
cin >> N >> D;
vector<int> V(N * N * 2 + D + 1);
for (int x = 1; x <= N; x++) {
for (int y = 1; y <= N; y++) V.at(x * x + y * y)++;
}
int ans = 0;
for (int w = 1; w <= N; w++) {
for (int z = 1; z <= N; z++) {
int tmp = w * w - z * z + D;
if (0 <= tmp && tmp < (int) V.size()) ans += V.at(tmp);
}
}
cout << ans << "\n";
}
ninoinui