AhmedAshraff

Untitled

Nov 23rd, 2024
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.53 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define boAshraf ios_base::sync_with_stdio(false); cin.tie(NULL);
  3. #define ll long long
  4. #define sz(s) (int)(s).size()
  5. #define all(s) (s).begin(),(s).end()
  6. using namespace std;
  7. void File();
  8. void sol();
  9. typedef long double ld;
  10. typedef complex<double> point;
  11. template<class T>
  12. istream& operator>>(istream& is, complex<T>& p) {
  13.     T value;
  14.     is >> value;
  15.     p.real(value);
  16.     is >> value;
  17.     p.imag(value);
  18.     return is;
  19. }
  20. #define PI acos(-1.0)
  21. #define EPS 1e-8
  22. #define X real()
  23. #define Y imag()
  24. #define angle(a)  (atan2((a).imag(), (a).real()))
  25. #define length(a)   (hypot((a).imag(), (a).real()))
  26. #define vec(a,b)  ((b)-(a))
  27. #define dp(a,b)   ( (conj(a)*(b)).real() )
  28. #define cp(a,b)   ( (conj(a)*(b)).imag() )
  29. #define normalize(a)(a)/length(a)
  30. bool same(point p1, point p2) {
  31.     return dp(vec(p1, p2), vec(p1, p2)) < EPS;
  32. }
  33. point rotate(point p, double angle, point around = point(0, 0)) {
  34.     p -= around;
  35.     return (p * exp(point(0, angle))) + around;
  36. }
  37. int main() {
  38.     boAshraf
  39.     File();
  40.     int t = 1;
  41. //    cin >> t;
  42.     while (t--) {
  43.         sol();
  44.     }
  45.     return 0;
  46. }
  47.  
  48. void sol() {
  49.     point p(0,0);
  50.     int n;
  51.     cin>>n;
  52.     while(n--){
  53.         double ang;
  54.         int d;
  55.         cin>>ang>>d;
  56.         ang*=PI/180;
  57.         point p2(d*cos(ang),d*sin(ang));
  58.         p+=p2;
  59.     }
  60.     cout<<fixed<<setprecision(8)<<length(p)<<'\n';
  61. }
  62.  
  63. void File() {
  64. #ifndef ONLINE_JUDGE
  65.     freopen("input.txt", "r", stdin);
  66.     freopen("output.txt", "w", stdout);
  67. #endif
  68. }
Advertisement
Add Comment
Please, Sign In to add comment