結果
問題 | No.800 四平方定理 |
ユーザー |
![]() |
提出日時 | 2019-03-17 22:30:26 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 545 bytes |
コンパイル時間 | 625 ms |
コンパイル使用メモリ | 72,112 KB |
実行使用メモリ | 18,064 KB |
最終ジャッジ日時 | 2024-07-08 00:30:13 |
合計ジャッジ時間 | 4,494 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 3 |
other | WA * 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;if (0 <= w2 and w2 <= n * n and sq[w2]) ans++;}}}cout << ans << endl;return 0;}