fork download
  1. // Nguyen Thien Nhan (tomato)
  2. #include <bits/stdc++.h>
  3. //#pragma GCC optimize("O3,unroll-loops")
  4. //#pragma GCC target("avx2,bmi,bmi2,popcnt")
  5.  
  6. using namespace std;
  7.  
  8. #define TASK "A"
  9. #define ll long long
  10. #define fi first
  11. #define se second
  12. #define BIT(x, i) (((x) >> (i)) & (1LL))
  13. #define MASK(i) ((1LL) << (i))
  14. #define ii pair<double, double>
  15.  
  16. template<class T> bool maximize(T &a, const T &b) {
  17. return a < b ? a = b, 1 : 0;
  18. }
  19.  
  20. template<class T> bool minimize(T &a, const T &b) {
  21. return a > b ? a = b, 1 : 0;
  22. }
  23.  
  24. const int MAXN = 1e4 + 5;
  25. const int MAXM = 2e5 + 5;
  26. const int MOD = 1e9 + 7;
  27. const int INF = 1e9;
  28.  
  29.  
  30. //---------Variable---------//
  31.  
  32. int numQuery;
  33. ii arr[MAXN];
  34.  
  35. //--------------------------//
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43. signed main() {
  44.  
  45. ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  46. // freopen(TASK".INP", "r", stdin);
  47. // freopen(TASK".OUT", "w", stdout);
  48.  
  49. int x, y;
  50. while(cin >> x >> y) {
  51. arr[++numQuery].fi = x;
  52. arr[numQuery].se = y;
  53. }
  54. for (int i = 1; i <= numQuery; ++i) {
  55. cout << "{";
  56. if (arr[i].fi != 0) cout << arr[i].fi;
  57. if (arr[i].se != 0) {
  58. if (arr[i].se == 1 || arr[i].se == -1) {
  59. if (arr[i].se == 1) cout << "+i";
  60. else cout << "-i";
  61. }
  62. else {
  63. if (arr[i].se > 0) cout << "+" << arr[i].se;
  64. else cout << arr[i].se;
  65. cout << "i";
  66. }
  67. }
  68. cout << "}" << " ";
  69. }
  70. cout << '\n';
  71. for (int i = 1; i <= numQuery; ++i) {
  72. int tmp = arr[i].fi * arr[i].fi + arr[i].se * arr[i].se;
  73. cout << fixed << setprecision(2) << sqrt(tmp) << " ";
  74. }
  75. cout << '\n';
  76. int curA = 0, curB = 0;
  77. for (int i = 1; i <= numQuery; ++i) {
  78. curA += arr[i].fi;
  79. curB += arr[i].se;
  80. }
  81. if (curA != 0) cout << curA;
  82. if (curB != 0) {
  83. if (curB == 1 || curB == -1) {
  84. if (curB == 1) cout << "+i";
  85. else cout << "-i";
  86. }
  87. else {
  88. if (curB> 0) cout << "+" << curB;
  89. else cout << curB;
  90. cout << "i";
  91. }
  92. }
  93.  
  94.  
  95. return 0;
  96.  
  97. }
  98.  
Success #stdin #stdout 0.01s 5296KB
stdin
Standard input is empty
stdout