結果
| 問題 |
No.800 四平方定理
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-03-17 22:44:52 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 666 bytes |
| コンパイル時間 | 1,613 ms |
| コンパイル使用メモリ | 166,028 KB |
| 実行使用メモリ | 62,848 KB |
| 最終ジャッジ日時 | 2024-07-08 01:01:40 |
| 合計ジャッジ時間 | 6,788 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 RE * 8 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MAXV = 5000000;
ll cnt1[MAXV + 1], cnt2[MAXV + 1];
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n, d;
cin >> n >> d;
for (int x = 1; x <= n; x++) {
for (int y = 1; y <= n; y++) {
cnt1[x * x + y * y]++;
}
}
for (int w = 1; w <= n; w++) {
int lim = min(n * n, w * w + d);
for (int z = 1; z * z <= lim; z++) {
cnt2[d + w * w - z * z]++;
}
}
ll ans = 0;
for (int i = 0; i <= MAXV; i++) {
ans += cnt1[i] * cnt2[i];
}
cout << ans << endl;
return 0;
}