結果
問題 | No.800 四平方定理 |
ユーザー | a |
提出日時 | 2019-03-17 21:46:34 |
言語 | C++14 (gcc 13.2.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 677 bytes |
コンパイル時間 | 1,529 ms |
コンパイル使用メモリ | 164,548 KB |
実行使用メモリ | 8,768 KB |
最終ジャッジ日時 | 2023-09-22 04:52:41 |
合計ジャッジ時間 | 8,330 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 13 ms
7,584 KB |
testcase_01 | AC | 28 ms
4,376 KB |
testcase_02 | AC | 19 ms
4,380 KB |
testcase_03 | AC | 20 ms
4,376 KB |
testcase_04 | AC | 15 ms
4,380 KB |
testcase_05 | AC | 18 ms
4,376 KB |
testcase_06 | AC | 36 ms
4,380 KB |
testcase_07 | AC | 29 ms
4,380 KB |
testcase_08 | AC | 68 ms
4,380 KB |
testcase_09 | AC | 31 ms
4,380 KB |
testcase_10 | TLE | - |
testcase_11 | TLE | - |
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; void solve() { int N, D, ans = 0; cin >> N >> D; for (int x = 1; x <= N; x++) { for (int y = x; y <= N; y++) { int p = abs(x * x + y * y - D); if (p == 0) { if (x == y) ans += N; else ans += 2*N; continue; } for (int k = 1; k * k <= p; k++) { if (p % k) continue; int z = ((p / k) + k) / 2; if ((k & 1) == ((p / k) & 1) && k != p / k && z <= N) { if (x == y) ans++; else ans += 2; //cout << x << ' ' << y << ' ' << k << ' ' << p/k << endl; } } } } cout << ans << endl; } int main(void) { solve(); //cout << "yui(*-v・)yui" << endl; return 0; }