您的位置:首页 > 其它

codeforces 342C Cupboard and Balloons(公式题)

2015-03-30 00:13 218 查看
转载请注明出处: http://www.cnblogs.com/fraud/ ——by fraud

C. Cupboard and Balloons

A girl named Xenia has a cupboard that looks like an arc from ahead. The arc is made of a semicircle with radius r (the cupboard's top) and two walls of height h (the cupboard's sides). The cupboard's depth is r, that is, it looks like a rectangle with base r and height h + rfrom the sides. The figure below shows what the cupboard looks like (the front view is on the left, the side view is on the right).

//#####################
//Author:fraud
//Blog: http://www.cnblogs.com/fraud/ //#####################
#include <iostream>
#include <sstream>
#include <ios>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <cctype>
using namespace std;
#define XINF INT_MAX
#define INF 0x3FFFFFFF
#define MP(X,Y) make_pair(X,Y)
#define PB(X) push_back(X)
#define REP(X,N) for(int X=0;X<N;X++)
#define REP2(X,L,R) for(int X=L;X<=R;X++)
#define DEP(X,R,L) for(int X=R;X>=L;X--)
#define CLR(A,X) memset(A,X,sizeof(A))
#define IT iterator
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<PII> VII;
typedef vector<int> VI;

int main()
{
ios::sync_with_stdio(false);
double r,h;
while(cin>>r>>h){
double tmp=(h+r/2);
int ans=(int)(tmp/r+1e-8);
tmp-=ans*r;
ans*=2;
tmp+=r/2;
if(tmp-r*(sqrt(3.0)/2)>-1e-12)ans++;
cout<<ans<<endl;

}
return 0;
}


代码君
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: