fork download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6. double a,b,c,d;
  7. cin >> a >> b >> c;
  8. d = b*b - 4 * a * c;
  9. if(int(a)==0 && int(b)==0 && int(c)==0){
  10. return cout << -1,0;
  11. }
  12. if(int(a)==0)
  13. return cout << 1 << '\n' << fixed << setprecision(6) << -c/b,0;
  14. if(d<0){
  15. cout << 0;
  16. } else {
  17. if(int(d)==0){
  18. cout << 1 << fixed << setprecision(6) << -b/(2*a);
  19. } else {
  20. d = sqrt(d);
  21. cout << 2 << '\n' << fixed << setprecision(6) << (-b+d)/(2*a) << '\n' << (-b-d)/(2*a);
  22. }
  23. }
  24.  
  25. }
Success #stdin #stdout 0s 3472KB
stdin
0 -1 6
stdout
1
6.000000