Guest User

Untitled

a guest
Jun 27th, 2017
333
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.70 KB | None | 0 0
  1. #include "bits/stdc++.h"
  2. using namespace std;
  3. typedef long long ll;
  4. typedef long double ld;
  5. ld pi = 3.14159265358979323846264 ;
  6. ld len(double a , double n , double r){
  7.             return (a * sin(pi * r / n)) / sin(pi / n);
  8. }
  9. struct r {
  10.             int i;
  11.             int j;
  12.             int k;
  13. };
  14. map < ld , r > store;
  15. ld ang(ld a , ld b , ld c){
  16.             return (180.0 / pi) * acos( (pow(a , 2) + pow(b , 2) - pow(c , 2)) / (2 * a * b) );
  17. }
  18. ld x = 1.2345;
  19. int main()
  20. {
  21.             ios_base::sync_with_stdio(false);
  22.             cin.tie(0);
  23.             cout.tie(0);
  24.             ll n;
  25.             ld a;
  26.             cin >> n >> a;
  27.             int num = 3;
  28.             if (n % 2 == 0){
  29.                     int th = 2;
  30.                     int se = 1;
  31.                     for(int i = 0 ; i < n / 2 - 1 ; i++){
  32.                             ld fir = x;
  33.                             ld sec = len(x , n , se);
  34.                             ld thi = len(x , n , th);
  35.                             if(store.find(abs(ang(fir , sec , thi) - a)) == store.end())
  36.                                 store[abs(ang(fir , sec , thi) - a)] = {1 , 2 , num};
  37.                             if(store.find(abs(ang(sec , fir , thi) - a)) == store.end())
  38.                                 store[abs(ang(sec , fir , thi) - a)] = {2 , 1 , num};
  39.                             if(store.find(abs(ang(sec , thi , fir) - a)) == store.end())
  40.                                 store[abs(ang(sec , thi , fir) - a)] = {2 , num , 1};
  41.                             se++;
  42.                             th++;
  43.                             num++;
  44.                     }
  45.             }
  46.             else{
  47.                     int th = 2;
  48.                     int se = 1;
  49.                     for(int i = 0 ; i < n / 2  ; i++){
  50.                             ld fir = x;
  51.                             ld sec = len(x , n , se);
  52.                             ld thi = len(x , n , th);
  53.                             if(store.find(abs(ang(fir , sec , thi) - a)) == store.end())
  54.                                 store[abs(ang(fir , sec , thi) - a)] = {1 , 2 , num};
  55.                             if(store.find(abs(ang(sec , fir , thi) - a)) == store.end())
  56.                                 store[abs(ang(sec , fir , thi) - a)] = {2 , 1 , num};
  57.                             if(store.find(abs(ang(sec , thi , fir) - a)) == store.end())
  58.                                 store[abs(ang(sec , thi , fir) - a)] = {2 , num , 1};
  59.                             se++;
  60.                             th++;
  61.                             num++;
  62.                     }
  63.             }
  64.             auto j = (*store.begin()).second;
  65.             cout << j.i << " " << j.j << " " << j.k << endl;
  66.             return 0;
  67. }
Add Comment
Please, Sign In to add comment