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. Linux的内存分页管理

    作者:Vamei 出处:http://www.cnblogs.com/vamei 严禁转载 内存是计算机的主存储器.内存为进程开辟出进程空间,让进程在其中保存数据.我将从内存的物理特性出发,深入到内存 ...

  2. MOCK API 的定义及实践(使用eolinker实现)

    MOCK API 的定义 根据百度百科的定义,mock测试就是在测试过程中,对于某些不容易构造或者不容易获取的对象,用一个虚拟的对象来创建以便测试的测试方法.这个虚拟的对象就是mock对象,mock对 ...

  3. Docker -v 对挂载的目录没有权限 Permission denied

    1.问题 今天在使用docker挂载redis的时候老是报错 docker run -v /home/redis/redis.conf:/usr/local/etc/redis/redis.conf ...

  4. Typora程序员的记事本.Typora常用快捷操作

    Typora常用快捷操作 1.文本格式快捷编写 1.1.文本段落编写 a)#→宫格建→加输入内容→回车键,其中#表示标题一,##表示标题二以此类推至######为止 b)或者选中要修改文本的文本格式按 ...

  5. js防抖和节流

    今天在网上看到的,里面的内容非常多.说下我自己的理解. 所谓的防抖就是利用延时器来使你的最后一次操作执行.而节流是利用时间差的办法,每一段时间执行一次.下面是我的代码: 这段代码是右侧的小滑块跟随页面 ...

  6. 去除inline-block元素间的间距

    一.现象描述 真正意义上的inline-block水平呈现的元素间,换行显示或者空格隔开的情况下会有间距,这是因为浏览器在解析时,会将换行等读取成一个空格导致. 二.移出空格的方法 ① 我们可以去掉元 ...

  7. [ArcGIS API for JavaScript 4.8] Sample Code-Get Started-MapView,SceneView简介

    [官方文档:https://developers.arcgis.com/javascript/latest/sample-code/index.html]  一.Intro to MapView(2D ...

  8. 2017-12-09 JavaScript实现ZLOGO子集: 测试用例

    续前文JavaScript实现ZLOGO子集: 前进+转向. 在添加新功能之前, 先添加测试用例, 以应对日益复杂的代码. 选择使用QUnit编写运行测试用例. 暂时对比较复杂和I/O无关的部分进行测 ...

  9. Altium Designer快速调整丝印

    Altium Designer快速调整丝印 今天我为大家讲的内容是altium designer快速调整丝印,这是我们做完PCB设计布线完成后的下一个步,很多朋友都是非常熟悉的.但是我们很多人只会用a ...

  10. 记一次DDOS攻击防御实录

    前言     笔者所在单位是一家小型创业公司,目前产品正在成长阶段,日活跃用户只有区区几万人次,并发只有日均 85/QPS,自建机房,带宽 100MB.在这样的背景下,完全没想过一个小产品会招来黑客的 ...