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的更多相关文章
随机推荐
- C# - 如何让类型可以比较
IComparable<T> .NET 里,IComparable<T>是用来作比较的最常用接口. 如果某个类型的实例需要与该类型的其它实例进行比较或者排序的话,那么该类型就可 ...
- AI - TensorFlow - 示例03:基本回归
基本回归 回归(Regression):https://www.tensorflow.org/tutorials/keras/basic_regression 主要步骤:数据部分 获取数据(Get t ...
- HSTS 详解,让 HTTPS 更安全
随着互联网的快速发展,人们在生活中越来越离不开互联网.无论是社交.购物还是搜索,互联网都能给人带来很多的便捷.与此同时,由于用户对网络安全的不了解和一些网站.协议的安全漏洞,让很多用户的个人信息数据“ ...
- 解决VS2019中.net core WPF 暂时无法使用 Designer 的临时方法
目录 解决 VS2019 中.net core WPF 暂时无法使用 Designer 的临时方法 安装 vs 2019 professional/enterprise版本 在vs的设置里,勾选.NE ...
- ES 15 - Elasticsearch中的数据类型 (text、keyword、date、geo等)
目录 1 核心数据类型 1.1 字符串类型 - string(不再支持) 1.1.1 文本类型 - text 1.1.2 关键字类型 - keyword 1.2 数字类型 - 8种 1.3 日期类型 ...
- SpringBoot进阶教程(二十六)整合Redis之共享Session
集群现在越来越常见,当我们项目搭建了集群,就会产生session共享问题.因为session是保存在服务器上面的.那么解决这一问题,大致有三个方案,1.通过nginx的负载均衡其中一种ip绑定来实现( ...
- 为什么VUE注册组件命名时不能用大写的?
这段时间一直在弄vue,当然也遇到很多问题,这里就来跟大家分享一些注册自定义模板组件的心得 首先"VUE注册组件命名时不能用大写"其实这句话是不对的,但我们很多人开始都觉得是对的, ...
- Unity C#笔记 协程
什么是协程 协同程序,在主程序运行的同时,开启另外一段逻辑处理,来协同当前程序的执行. 可能看了这段文字介绍还是有点模糊,其实可以用多线程来比较. 多线程 多线程,顾名思义,多条同时执行的线程. 最初 ...
- Android-----Intent中通过startActivity(Intent intent )隐式启动新的Activity
显式Intent我已经简单使用过了,也介绍过概念,现在来说一说隐式Intent: 隐式Intent:就是只在Intent中设置要进行的动作,可以用setAction()和setData()来填入要执行 ...
- Android权限禁止及友好提示用户开通必要权限
Android权限 Android安全架构规定:默认情况下,任何应用都没有权限执行对其他应用.操作系统或用户有不利影响的任何操作.这包括读写用户的私有数据(联系人,短信,相册,位置).读写其他应用的文 ...