Guest User

Untitled

a guest
Jun 27th, 2017
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.09 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.             ld n;
  25.             ld a;
  26.             cin >> n >> a;
  27.             store[abs(180.0 * (n - 2) / n - a)] = {1 , 2 , 3};
  28.             int num = 3;
  29.             if(n > 3){
  30.                     if ((int)n % 2 == 0){
  31.                             int th = 2;
  32.                             int se = 1;
  33.                             for(int i = 0 ; i < n / 2 - 1 ; i++){
  34.                                     ld fir = x;
  35.                                     ld sec = len(x , n , se);
  36.                                     ld thi = len(x , n , th);
  37.                                     if(store.find(abs(ang(fir , sec , thi) - a)) == store.end())
  38.                                         store[abs(ang(fir , sec , thi) - a)] = {1 , 2 , num};
  39.                                     if(store.find(abs(ang(sec , fir , thi) - a)) == store.end())
  40.                                         store[abs(ang(sec , fir , thi) - a)] = {2 , 1 , num};
  41.                                     if(store.find(abs(ang(sec , thi , fir) - a)) == store.end())
  42.                                         store[abs(ang(sec , thi , fir) - a)] = {2 , num , 1};
  43.                                     se++;
  44.                                     th++;
  45.                                     num++;
  46.                             }
  47.                     }
  48.                     else{
  49.                             int th = 2;
  50.                             int se = 1;
  51.                             for(int i = 0 ; i < n / 2  ; i++){
  52.                                     ld fir = x;
  53.                                     ld sec = len(x , n , se);
  54.                                     ld thi = len(x , n , th);
  55.                                     if(store.find(abs(ang(fir , sec , thi) - a)) == store.end())
  56.                                         store[abs(ang(fir , sec , thi) - a)] = {1 , 2 , num};
  57.                                     if(store.find(abs(ang(sec , fir , thi) - a)) == store.end())
  58.                                         store[abs(ang(sec , fir , thi) - a)] = {2 , 1 , num};
  59.                                     if(store.find(abs(ang(sec , thi , fir) - a)) == store.end())
  60.                                         store[abs(ang(sec , thi , fir) - a)] = {2 , num , 1};
  61.                                     se++;
  62.                                     th++;
  63.                                     num++;
  64.                             }
  65.                     }
  66.             }
  67.             auto j = (*store.begin()).second;
  68.             cout << j.i << " " << j.j << " " << j.k << endl;
  69.             return 0;
  70. }
Add Comment
Please, Sign In to add comment