結果
| 問題 |
No.800 四平方定理
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-03-17 21:32:33 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 75 ms / 2,000 ms |
| コード長 | 564 bytes |
| コンパイル時間 | 1,679 ms |
| コンパイル使用メモリ | 167,708 KB |
| 実行使用メモリ | 34,616 KB |
| 最終ジャッジ日時 | 2024-07-07 20:49:51 |
| 合計ジャッジ時間 | 3,534 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;
int main() {
int n, d; scanf("%d%d", &n, &d);
std::vector<int> vec(2 * n * n + 1, 0);
for(i64 i = 1; i <= n; i++) {
for(i64 j = 1; j <= n; j++) {
vec[i * i + j * j]++;
}
}
i64 ans = 0;
for(i64 i = 1; i <= n; i++) {
for(i64 j = 1; j <= n; j++) {
i64 latte = i * i - j * j + d;
if(latte > vec.size() or latte < 0) continue;
ans += vec[latte];
}
}
printf("%lld\n", ans);
return 0;
}