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虚拟机之java内存区域

    java虚拟机在执行java程序的时候会把它所管理的内存分为多个不同的区域,每个区域都有不同的作用,以及由各自的生命周期,有些随着虚拟机进行的启动而存在,有些区域则依赖于用户线程的启动或结束而建立或销 ...

  2. mariaDB vs mysql

    mariaDB vs mysql 今天遇到一个库使用的是mariaDB的数据库版本 Server version: 10.1.20-MariaDB MariaDB Server 理了一下mariaDB ...

  3. 简述Java中的final关键字

    final关键字可用于修饰类.方法和变量,final修饰的类不能被继承:final修饰的方法不可被重写:final修饰的变量不可被改变. 1. final类 final修饰的类不能被继承意思是fina ...

  4. 关于Python中读取写入文件并进行文件与用户交互的操作

    一.提前知识点 在python中是同样和其他语言一样可以进行文件的读取写入操作,值得注意的是,Python中打开文件读取的方式有几种,分别是以下几种: f = open('username.txt') ...

  5. LeetCode算法题-Rotated Digits(Java实现)

    这是悦乐书的第316次更新,第337篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第185题(顺位题号是788).如果一个数字经过180度旋转后,变成了一个与原数字不同的 ...

  6. 部署远程jupyter

    1.直接执行 pip3 install jupyter 2.无法执行jupyter notebook后报错 “jupyter:command not found” 3.找到安装的位置,一般都在pyth ...

  7. 史上最全的springboot导出pdf文件

    最近项目有一个导出报表文件的需求,我脑中闪过第一念头就是导出pdf(产品经理没有硬性规定导出excel还是pdf文件),于是赶紧上网查看相关的资料,直到踩了无数的坑把功能做出来了才知道其实导出exce ...

  8. 深入介绍Java中的锁[原理、锁优化、CAS、AQS]

    1.为什么要用锁? 锁-是为了解决并发操作引起的脏读.数据不一致的问题. 2.锁实现的基本原理 2.1.volatile Java编程语言允许线程访问共享变量, 为了确保共享变量能被准确和一致地更新, ...

  9. String字符串创建与存储机制

    Java内存可以粗略的区分为堆内存(Heap)和栈内存(Stack),堆中存放的是对象实例,而栈中存放的则是方法调用过程中的局部变量或引用等. 在Java语言中,字符串的生命与初始化有如下两种方式: ...

  10. 【Spark篇】---SparkStreaming中算子中OutPutOperator类算子

    一.前述 SparkStreaming中的算子分为两类,一类是Transformation类算子,一类是OutPutOperator类算子. Transformation类算子updateStateB ...