結果
問題 | No.800 四平方定理 |
ユーザー | @abcde |
提出日時 | 2019-03-17 22:01:08 |
言語 | C++11 (gcc 11.4.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,135 bytes |
コンパイル時間 | 1,261 ms |
コンパイル使用メモリ | 144,796 KB |
実行使用メモリ | 7,756 KB |
最終ジャッジ日時 | 2023-09-22 06:05:05 |
合計ジャッジ時間 | 5,238 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 11 ms
4,384 KB |
testcase_01 | AC | 26 ms
4,376 KB |
testcase_02 | AC | 16 ms
4,376 KB |
testcase_03 | AC | 19 ms
4,380 KB |
testcase_04 | AC | 15 ms
4,380 KB |
testcase_05 | AC | 18 ms
4,384 KB |
testcase_06 | AC | 32 ms
4,376 KB |
testcase_07 | AC | 28 ms
4,380 KB |
testcase_08 | AC | 44 ms
4,384 KB |
testcase_09 | AC | 27 ms
4,380 KB |
testcase_10 | TLE | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { // 1. 入力情報取得. int N, D; cin >> N >> D; // 2. 解を確認. int ans = 0; for(int x = 1; x < N + 1; x++){ for(int y = x; y < N + 1; y++){ for(int z = y; z < N + 1; z++){ int c = x * x + y * y + z * z - D; int w = sqrt(c + 0.0); if(c == w * w && w <= N && w >= 1){ if(x != y && y != z && z != x) ans += 6; if(x != y && y != z && z == x) ans += 3; if(x != y && y == z && z != x) ans += 3; if(x == y && y != z && z != x) ans += 3; if(x != y && y == z && z == x) ans += 2; if(x == y && y != z && z == x) ans += 2; if(x == y && y == z && z != x) ans += 2; if(x == y && y == z && z == x) ans += 1; // cout << "x=" << x << " y=" << y << " z=" << z << " w=" << w << endl; } } } } // 3. 後処理. cout << ans << endl; return 0; }