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. 线性表概述及单链表的Java实现

    一.线性表概述 线性表是指一组数据元素之间具有线性关系的元素序列,它表现为:除第一个元素没有直接前驱元素.最后一个元素没有直接后继元素外,其余所有元素都有且仅有一个直接前驱元素和直接后继元素. 根据存 ...

  2. 一次搞懂 Generator 函数

    1.什么是 Generator 函数 在Javascript中,一个函数一旦开始执行,就会运行到最后或遇到return时结束,运行期间不会有其它代码能够打断它,也不能从外部再传入值到函数体内 而Gen ...

  3. .NET Core微服务系列基础文章索引(目录导航Final版)

    一.为啥要总结和收集这个系列? 今年从原来的Team里面被抽出来加入了新的Team,开始做Java微服务的开发工作,接触了Spring Boot, Spring Cloud等技术栈,对微服务这种架构有 ...

  4. 设计模式之组合模式——Java语言描述

    组合模式又叫做部分整体模式,适用于把一组相似的对象当作一个单一的对象.组合模式依据树形结构来组合对象,用来表示部分以及整体层次 介绍 意图 将对象组合成树形结构以表示"部分-整体" ...

  5. GDAL读取的坐标起点在像素左上角还是像素中心?

    目录 1. 问题 2. 结论 3. 例外 1. 问题 笔者在处理地理栅格数据的时候,总是会发生偏差半个像素的问题. 比如说通过ArcMap打开一张.tif,查看其地理信息:同时用记事本打开.tfw,比 ...

  6. 关于微信JS-SDK 分享接口的两个报错记录

    一.前提: 微信测试号,用微信开发者工具测试 二.简单复述文档: 1.引入JS文件 在需要调用JS接口的页面引入如下JS文件,(支持https):http://res.wx.qq.com/open/j ...

  7. centos7 ambari安装HDP

    环境介绍:操作系统为Centos7.1:测试设备全部为内网设备,不通公网,所以需要配置本地yum源: 首先安装ansible工具,用来批量安装ambari.java以及基础的一些配置: 一. 免密钥登 ...

  8. golang 变量定义

    package main import "fmt" var luckyNum = 6 var luckyStr = "love" //myNum := 6 // ...

  9. windows之自动化在虚拟机部署操作系统并自带python环境

    (1)使用详情: **************************** *    操作说明     * **************************** 1.修改Config文件夹中的Se ...

  10. 《Python黑客编程之极速入门》正式开课

    玄魂 玄魂工作室 今天 之前开启了一个<Python黑客编程>的系列,后来中断了,内容当时设置的比较宽,不太适合入门.现在将其拆分成两个系列<Python黑客编程之极速入门>和 ...