Yeehaa!
Time Limit: 1000MS   Memory Limit: 30000K
Total Submissions: 15082   Accepted: 6675

Description

Background 
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

The first line contains the number of scenarios. For each scenario follows a line containing a real number R and an integer n, with 1 <= R <= 100 and 2 <= n <= 100.

Output

The output for every scenario begins with a line containing "Scenario #i:", where i is the number of the scenario starting at 1. Then print the value for r, rounded to three decimal places. Terminate the output for the scenario with a blank line.

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

TUD Programming Contest 2004, Darmstadt, Germany
 
#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的更多相关文章

随机推荐

  1. Python进阶:设计模式之迭代器模式

    在软件开发领域中,人们经常会用到这一个概念——“设计模式”(design pattern),它是一种针对软件设计的共性问题而提出的解决方案.在一本圣经级的书籍<设计模式:可复用面向对象软件的基础 ...

  2. windows代码,传入文件名,遍历此目录下所有文件.

    #include <windows.h> #include <vector> using namespace std; BOOL IterAtorFileSaveFile(IN ...

  3. [PHP]日志处理error_log()函数和配置使用

    1.error_log($message,$message_type,$destination,$extra_headers)函数, 2.message_type 是0,发送信息到php.ini配置的 ...

  4. jquery.rotate.js实现可选抽奖次数和中奖内容的转盘抽奖代码

    需求: 抽奖代码最多可以抽奖5次,而且,每次只会中“2000元理财金”或者“谢谢参与”,其它的不会抽中(哈哈,果然都是套路). 效果如下: 一.页面结构: ? 1 2 3 4 5 6 7 8 9 10 ...

  5. 移动端布局方案汇总&&原理解析

    阿里flexible布局 - 版本1.x 该布局于 2017年8月9日被2.0版本取代 实现原理 假设(UI稿750px宽) 设置viewport的 scale = 1/window.devicePi ...

  6. HTML 练习实现遮罩层

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  7. ArcGIS API for JavaScript 4.x 本地部署之跨域问题解决法:CORS

    众所周知,在离线部署ArcGIS API for JavaScript时,有时候会产生微件上的字体.符号变成方框的问题.这是遇到了跨域,只需要对所在服务器进行配置即可. 本篇使用的环境是:API配置在 ...

  8. GIS大数据存储预研

    文章版权由作者李晓晖和博客园共有,若转载请于明显处标明出处:http://www.cnblogs.com/naaoveGIS/ 1. 背景 在实际项目运行中,时常会出现希望搜索周边所有数据的需求.但是 ...

  9. SQL内模糊查询语句拼接时单引号'问题

    下面以存储过程查询所有为例,非存储过程(或不是查询所有将*替换为你想要查询的列即可)更为简单, 语法:select * from 表名 where 列名like'%条件%' 拼接后的set @变量名 ...

  10. netdom remove 错误:netdom remove

    自己用错了命令,直接将加入域的计算机使用dsrm删除了,本来应该使用netdom remove的,结果在域控制器上使用netdom remove错误,在客户端上登录时一样提示:netdom remov ...