結果
| 問題 |
No.800 四平方定理
|
| コンテスト | |
| ユーザー |
ikd
|
| 提出日時 | 2019-03-17 22:31:50 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 549 bytes |
| コンパイル時間 | 528 ms |
| コンパイル使用メモリ | 72,276 KB |
| 実行使用メモリ | 17,928 KB |
| 最終ジャッジ日時 | 2024-07-08 00:32:53 |
| 合計ジャッジ時間 | 4,318 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | AC * 10 TLE * 1 -- * 19 |
ソースコード
#include <algorithm>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main() {
int n, d;
cin >> n >> d;
vector<int> sq(n * n + 1, false);
for (int i = 1; i <= n; i++) {
sq[i * i] = true;
}
int ans = 0;
for (int x = 1; x <= n; x++) {
for (int y = 1; y <= n; y++) {
for (int z = 1; z <= n; z++) {
auto w2 = x * x + y * y + z * z - d;
if (0 <= w2 and w2 <= n * n and sq[w2]) ans++;
}
}
}
cout << ans << endl;
return 0;
}
ikd