2013
11-10

# Yeehaa!

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.

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.

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.

4
4.0 6
4.0 17
3.14159 100
42 2

Scenario #1:
1.333

Scenario #2:
0.621

Scenario #3:
0.096

Scenario #4:
21.000


//* @author popop0p0popo
import java.util.*;
import java.io.*;
import java.text.*;

public class Main{
public static void main(String[] args){
int n=scanner.nextInt();
double r,t;
for (int i=0;i< n ;i++ ){
r=scanner.nextDouble();
t=scanner.nextDouble();
System.out.println("Scenario #"+(i+1)+":");
DecimalFormat df=new DecimalFormat("0.000");
System.out.println(df.format(r*(1.0-1.0/(1.0+Math.sin(Math.PI/t)))));
System.out.println();
}
}
}

1. 给你一组数据吧：29 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 1000。此时的数据量还是很小的，耗时却不短。这种方法确实可以，当然或许还有其他的优化方案，但是优化只能针对某些数据，不太可能在所有情况下都能在可接受的时间内求解出答案。

2. Gucci New Fall Arrivals

This is really nice to know. I hope it will be successful in the future. Good job on this and keep up the good work.

3. 第一题是不是可以这样想，生了n孩子的家庭等价于n个家庭各生了一个1个孩子，这样最后男女的比例还是1:1