1 条题解
-
0
输入可以用 char 吃掉多余单个字符,然后读整数的方法读每个整数。也可以直接不停读字符然后处理。 第一行的内容就是要细致,按题目要求一点点处理。
第二行会用一元二次方程求根公式。
#include <bits/stdc++.h> #define int long long using namespace std; char t; int i, n, j, m; signed main() { freopen("uqe.in","r",stdin); freopen("uqe.out","w",stdout); cin >> t >> i >> t >> t >> n >> t; // (ix+n) cin >> t >> j >> t >> t >> m >> t; // (jx+m) int a = i * j; int b = i * m + j * n; int c = n * m; if (a != 0) { if (a != 1) cout << a; cout << "x^2"; } if (b != 0) { if (a != 0) cout << "+"; if (b != 1) cout << b; cout << "x"; } if (c != 0) { if (a != 0 || b != 0) cout << "+"; cout << c; } cout << "\n"; bool flag = false; int ans; if (a == 0 && b == 0) { if (c == 0) flag = true, ans = 33; } else if (a == 0) { if (c % b == 0) flag = true, ans = -c / b; } else { // (ix+n)(jx+m) if (n % i == 0) flag = true, ans = -n / i; if (m % j == 0) flag = true, ans = -m / j; } if (flag) cout << ans << "\n"; else cout << "No\n"; return 0; }
- 1
信息
- ID
- 1022
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 7
- 标签
- 递交数
- 49
- 已通过
- 11
- 上传者