何晨光的代码(我的代码长度偏短)

一心净土  •  14天前


include <bits/stdc++.h>

using namespace std;typedef long long ll;int main() {int k;ll n, e, d, m;cin >> k;while (k--) {cin >> n >> e >> d;m = n - e d + 2;ll f = m m - 4 * n; if (f < 0) { cout << "NO" << endl; } else { int c = 0; ll x1, x2; ll g = sqrt(f); if ((m + g) % 2 == 0) { x1 = (m + g) / 2; c++; } if ((m - g) % 2 == 0) { x2 = (m - g) / 2; c++; } if (c == 2) { if (x1 < x2) cout << x1 << " " << x2 << endl; else cout << x2 << " " << x1 << endl; } else cout << "NO" << endl; } } return 0;}


评论:

请先登录,才能进行评论