當(dāng)前位置:
首頁(yè) >
Codeforces Round #421 B
發(fā)布時(shí)間:2024/9/5
42
豆豆
生活随笔
收集整理的這篇文章主要介紹了
Codeforces Round #421 B
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
B. Mister B and Angle in Polygon
題意:給你一個(gè)正n邊形(每個(gè)點(diǎn)順時(shí)針依次為1 2 3...n),一個(gè)角度a,從多邊形中任選3個(gè)點(diǎn)A B C 求最接近a的角ABC 輸出ABC
思路:將n多邊形外接一個(gè)圓,可知,當(dāng)2個(gè)點(diǎn)確定的時(shí)候,角度就已經(jīng)確定了(只考慮小于180度的情況),所以,確定一個(gè)點(diǎn)之后暴力另一個(gè)點(diǎn)就可以求得所有情況了(注意只要暴力到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 */?
轉(zhuǎn)載于:https://www.cnblogs.com/max88888888/p/7091939.html
總結(jié)
以上是生活随笔為你收集整理的Codeforces Round #421 B的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 网络组Network Teaming
- 下一篇: 快速了解一门技术的基本步骤