Codeforces Round #421 B
生活随笔
收集整理的這篇文章主要介紹了
Codeforces Round #421 B
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
B. Mister B and Angle in Polygon
題意:給你一個正n邊形(每個點順時針依次為1 2 3...n),一個角度a,從多邊形中任選3個點A B C 求最接近a的角ABC 輸出ABC
思路:將n多邊形外接一個圓,可知,當2個點確定的時候,角度就已經確定了(只考慮小于180度的情況),所以,確定一個點之后暴力另一個點就可以求得所有情況了(注意只要暴力到n-2就可以了)
AC代碼:
#include "iostream" #include "string.h" #include "stack" #include "queue" #include "string" #include "vector" #include "set" #include "map" #include "algorithm" #include "stdio.h" #include "math.h" #define ll long long #define bug(x) cout<<x<<" "<<"UUUUU"<<endl; #define mem(a) memset(a,0,sizeof(a)) using namespace std; const int N=1e5+100; int n,a; double an,an1,ab=365,ans; int main(){cin>>n>>a;for(int i=1; i<n-1; ++i){an=180.0*i/n;if(fabs(an-a)<ab){ab=fabs(an-a);ans=i+1;}}if(ans==2) cout<<"1 3 "<<ans;else cout<<"1 "<<ans+1<<" "<<ans;return 0; }/* 3 15 4 67 4 68 */?
轉載于:https://www.cnblogs.com/max88888888/p/7091939.html
總結
以上是生活随笔為你收集整理的Codeforces Round #421 B的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 网络组Network Teaming
- 下一篇: Oracle数据库的视图