Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- const short LOVE = 1411;
- const int INF = 1 << 30;
- typedef long double db;
- void query() {
- db a, b, c; cin >> a >> b >> c;
- int ans;
- if (a == 0 && b == 0)
- if (c == 0)
- ans = INF;
- else
- ans = 0;
- else {
- vector<db> p;
- set<db> s;
- db delta;
- if (a == 0)
- p = {-c / b};
- else if (delta = b * b - 4 * a * c, delta >= 0)
- p = {(-b - sqrt(delta)) / (2*a), (-b + sqrt(delta)) / (2*a)};
- for (db no : p)
- if (no >= 0)
- s.insert(sqrt(no)),
- s.insert(-sqrt(no));
- ans = s.size();
- }
- if (ans == 0)
- cout << "phuong trinh vo nghiem";
- else if (ans == INF)
- cout << "phuong trinh vo so nghiem";
- else
- cout << "phuong trinh co " << ans << " nghiem";
- }
- int main() {
- //freopen("Test.INP", "r", stdin);
- //freopen("Test.OUT", "w", stdout);
- cin.tie(NULL)->sync_with_stdio(false);
- int t; for (t = 1; t--;) query();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement