Poj1799
| Time Limit: 1000MS | Memory Limit: 30000K | |
| Total Submissions: 15082 | Accepted: 6675 |
Description
George B. wants to be more than just a good American. He wants to make his daddy proud and become a western hero. You know, like John Wayne.
But sneaky as he is, he wants a special revolver that will allow him to shoot more often than just the usual six times. This way he can fool and kill the enemy easily (at least that's what he thinks).
Problem
George has kidnapped ... uh, I mean ... "invited" you and will only let you go if you help him with the math. The piece of the revolver that contains the bullets looks like this (examples for 6 and 17 bullets):

There is a large circle with radius R and n little circles with radius r that are placed inside on the border of the large circle. George wants his bullets to be as large as possible, so there should be no space between the circles. George will decide how large the whole revolver will be and how many bullets it shall contain.Your job is, given R and n, to compute r.
Input
Output
Sample Input
4 4.0 6 4.0 17 3.14159 100 42 2
Sample Output
Scenario #1: 1.333 Scenario #2: 0.621 Scenario #3: 0.096 Scenario #4: 21.000
Source
#include<iostream>
#include<vector>
#include<cmath>
#include<iomanip>
using namespace std;
const double PI= acos(-1.0);
int main()
{
int N;
cin>>N;
vector<float>arr(N*2);
for(int i=0;i<arr.size();i++)
{
cin>>arr[i];
}
int counter =0;
for(int i=1;i<=N;i++)
{
cout<<"Scenario #"<<i<<":"<<endl;
float R=arr[counter];
int n=arr[counter+1];
float r;
r = (sin(PI/(n*1.0))* R) / (1+sin(PI/(n*1.0)));
cout<<setiosflags(ios::fixed);
cout<<setprecision(3)<<r<<endl<<endl;
counter+=2;
}
return 0;
}
Poj1799的更多相关文章
随机推荐
- ThreadLocal的应用与实现原理
本文对ThreadLocal的分析基于JDK 8. 本文大纲 1. ThreadLocal快速上手 2. ThreadLocal应用场景 3. TheadLocal set与get方法简析 4. Th ...
- 记一次重大生产事故,在那 0.1s 我想辞职不干了!
一.发生了什么? 1.那是一个阳光明媚的下午,老婆和她的闺蜜正在美丽的湖边公园闲逛(我是拎包拍照的). 2.突然接到甲方运营小妹的微信:有个顾客线上付款了,但是没有到账,后台卡在微信支付成功(正常状态 ...
- MIPCache 域名升级
一.MIPCache URL 是什么 举个例子,MIP 官网的 URL 为: https://www.mipengine.org 对应的 MIPCache 的 URL 为: https://mipca ...
- JAVA使用POI获取Excel的列数与行数
Apache POI 是用Java编写的免费开源的跨平台的 Java API,Apache POI提供API给Java程式对Microsoft Office格式档案读和写的功能. 下面这篇文章给大家介 ...
- PdfReader按页将PDF切割成多个PDF
private MemoryStream GetNewPdfByPageNum(PdfReader pdfReader, int pageNum) { MemoryStream memoryStrea ...
- SQLSERVER数据库死锁与优化杂谈
死锁杂谈 当数据库死锁时,SqlServer会释放一个优先级较低的锁,让另一个事务运行:所以,即时去捕捉数据库死锁,是挺不容易的. 如果,数据库死锁比较长时间,那么死锁是可以被捕捉的. 可以用SqlS ...
- SpringIOC原理简述
IOC:控制反转(Inversion of Control,英文缩写为 IOC) 简单来讲就是把代码的控制权从调用方(用户)转变成被调用方(服务端) 以前的代码控制权在调用方,所以要每当程序要更新修改 ...
- 『vue踩坑日常』 在index.html中引入静态文件不生效
Vue日常踩坑日常 -- 在index.html中引入静态文件不生效问题 本文针对的是Vue小白,不喜勿喷,谢谢 出现该问题的标志如下 控制台warning(Resource interpreted ...
- html 中 xmp标记
HTML页面中显示HTML标签代码,可以使用<xmp>html标签内容</xmp>,这样,在网页中就会显示html标签 for(var i=0;i<columns.len ...
- 1.App Inventor 2简介
App Inventor 原是Google实验室(Google Lab)的一个子计划,由一群Google工程师和勇于挑战的Google使用者共同参与设计完成.Google App Inventor是一 ...