Anik_Akash

1020. Rope

Jan 18th, 2021 (edited)
626
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<bits/stdc++.h>
  2. using namespace    std;
  3.  
  4. #define flush        cin.ignore(numeric_limits<streamsize>::max(),'\n')
  5. #define fasterio     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
  6. #define NL           printf("\n")
  7.  
  8.  
  9.  
  10. //who cares? I want to give some scary looks to my code... XD//
  11.  
  12.  
  13. typedef long long int       ll;
  14. typedef double              dl;
  15. typedef unsigned long long  ul;
  16.  
  17. // ------------------------------------Constants-------------------------------------//
  18.  
  19. #define pi           (acos(-1.0)) //3.1415926535897932384626
  20. #define mx           7500000
  21. #define dpoint(x)    fixed<<setprecision(x)
  22. #define mod          1000000007
  23. #define pb(x)        push_back(x)
  24. #define scn(x)       scanf("%d",&x)
  25. #define scnd(x)      scanf("%lf",&x)
  26.        
  27.  
  28. // --------------------------Pre made Functions & Proto Type--------------------------//
  29.  
  30. template <class T> T gcd(T a, T b){if(a == 0) return b;return gcd ( b%a, a );}
  31. template <class T> T lcm(T a, T b){return ( ( a/gcd ( a, b ) )*b );}
  32. template <class T> T digitsum(T n){T sum=0;while(n!=0){sum+=n%10;n/=10;}return sum;}
  33.  
  34. void print(int n, int c){
  35.   if(c==n+1) return;
  36.   print(n,c+1);
  37.   cout<<c<<" ";
  38.  
  39. }
  40.  
  41.  
  42.  // --------------------------------------Global--------------------------------------//
  43.  
  44.  
  45.  // -------------------------------------slove----------------------------------------//
  46.  //Code Status :ac ;name: Unlucky Bird;
  47. int main()
  48. {
  49.     #ifndef ONLINE_JUDGE
  50.         freopen("int.txt","r",stdin);
  51.         freopen("ans2.txt","w",stdout);
  52.     #endif
  53.          int n,r;
  54.          cin>>n>>r;
  55.          std::vector<dl> first;
  56.          std::vector<dl> secound;
  57.          for(int i=0; i<n; i++){
  58.             dl x,y;
  59.             cin>>x>>y;
  60.             first.pb(x);
  61.             secound.pb(y);
  62.          }
  63.          dl d = sqrt(((first[0]-first[n-1])*(first[0]-first[n-1]))+((secound[0]-secound[n-1])*(secound[0]-secound[n-1])));
  64.  
  65.          for(int i=0; i<n-1; i++){
  66.             d += sqrt(((first[i]-first[i+1])*(first[i]-first[i+1]))+((secound[i]-secound[i+1])*(secound[i]-secound[i+1])));
  67.          }
  68.          dl ans = d+(2*pi*r);
  69.          cout<< dpoint(2)<<ans<<endl;
  70.          
  71.     return 0;
  72. }
  73. /// ----------------------------Funaction Descriptions----------------------------------//
  74.  
  75.  
  76. //author anikaksh;
  77. //trust me ur the competitor of your own, not ur friend!
  78. //Thanks To My Seniors and frndzz who help me all the time's
  79. //Contest link:https://lightoj.com/problem/1311?problem=1311
  80.  
RAW Paste Data