結果
| 問題 |
No.800 四平方定理
|
| コンテスト | |
| ユーザー |
t33f
|
| 提出日時 | 2019-03-17 22:46:47 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 535 bytes |
| コンパイル時間 | 668 ms |
| コンパイル使用メモリ | 74,992 KB |
| 実行使用メモリ | 23,936 KB |
| 最終ジャッジ日時 | 2024-07-08 01:06:44 |
| 合計ジャッジ時間 | 4,599 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 RE * 8 |
ソースコード
#include <cmath>
#include <vector>
#include <iostream>
using namespace std;
int main() {
int n, D; cin >> n >> D;
constexpr int N = 5'000'001;
vector<int> div(N, 0);
for (int d = 1; d <= n; d++)
for (int m = d+2; m <= 2*n - d && m * d < N; m += 2)
div[m*d]++;
long long ans = 0;
for (int x = 1; x <= n; x++)
for (int y = 1; y <= n; y++) {
int v = abs(x*x + y*y - D);
if (v == 0) ans += n;
else ans += div[v];
}
cout << ans << endl;
}
t33f