fork(3) download
  1. #include <bits/stdc++.h>
  2. #define endl "\n"
  3. #define rep(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
  4. #define fi first
  5. #define se second
  6. using namespace std;
  7. typedef long long ll;
  8. typedef long double ld;
  9.  
  10. ld slove(ld n) {
  11. if (n == (ld)0) return 0;
  12. ld denta = n*n - 4*n;
  13. if (denta < (ld)0) return 0;
  14. if (denta == (ld)0) return n/(ld)2;
  15. ld arr[4];
  16. arr[0] = (n - sqrt(denta)) / (ld)2;
  17. arr[1] = (n + sqrt(denta)) / (ld)2;
  18. arr[2] = (arr[0] == (ld)0) ? -1 : n/arr[0];
  19. arr[3] = (arr[1] == (ld)0) ? -1 : n/arr[1];
  20. sort(arr, arr+4);
  21. rep(i, 0, 4) if (arr[i] > (ld)0) return arr[i];
  22. return 0;
  23. }
  24.  
  25. int main(){
  26. #ifdef ONLINE_JUDGE
  27. SPEED
  28. #endif
  29. #ifndef ONLINE_JUDGE
  30. //freopen("in.cpp", "r", stdin);
  31. freopen("out.cpp", "wt", stdout);
  32. #endif
  33. }
  34. {/*-----Code-----*/}
  35. cout << fixed << setprecision(15);
  36. //vector<ld> ans;
  37. ld n;
  38. cin >> n;
  39. deque<ld> ans;
  40. ans.push_back(n);
  41. for (int i = 0; i < ans.size(); i++) {
  42. ld tmp = slove(ans[i]);
  43. if (tmp == (ld)0) continue;
  44. ans.push_back(tmp);
  45. ans.push_back(ans[i]-tmp);
  46. ans.erase(ans.begin()+i);
  47. i--;
  48. }
  49. sort(ans.begin(), ans.end());
  50. for (ld i:ans) cout << i << endl;;
  51. return 0;
  52. }
  53.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:27:4: error: ‘SPEED’ was not declared in this scope
    SPEED
    ^~~~~
prog.cpp: At global scope:
prog.cpp:34:2: error: expected unqualified-id before ‘{’ token
  {/*-----Code-----*/}
  ^
prog.cpp:35:2: error: ‘cout’ does not name a type; did you mean ‘cosl’?
  cout << fixed << setprecision(15);
  ^~~~
  cosl
prog.cpp:38:2: error: ‘cin’ does not name a type; did you mean ‘sin’?
  cin >> n;
  ^~~
  sin
prog.cpp:40:2: error: ‘ans’ does not name a type
  ans.push_back(n);
  ^~~
prog.cpp:41:2: error: expected unqualified-id before ‘for’
  for (int i = 0; i < ans.size(); i++) {
  ^~~
prog.cpp:41:18: error: ‘i’ does not name a type
  for (int i = 0; i < ans.size(); i++) {
                  ^
prog.cpp:41:34: error: ‘i’ does not name a type
  for (int i = 0; i < ans.size(); i++) {
                                  ^
prog.cpp:49:6: error: expected constructor, destructor, or type conversion before ‘(’ token
  sort(ans.begin(), ans.end());
      ^
prog.cpp:50:2: error: expected unqualified-id before ‘for’
  for (ld i:ans) cout << i << endl;;
  ^~~
prog.cpp:51:2: error: expected unqualified-id before ‘return’
  return 0;
  ^~~~~~
prog.cpp:52:1: error: expected declaration before ‘}’ token
 }
 ^
stdout
Standard output is empty