2014
11-05

# How high is the Building

One day, zp, wangchaohui and snowingsea passed by Science Building on the way to have dinner, after their working on puzzle.

zp asks:”Do you know how high the building is?”, but none of them knew. "So let’s measure it!", snowingsea shouted out. Then they borrowed n theodolites（a tool used to measure angle of elevation）. The n theodolites were placed on the ground around the building, which formed an n-edge regular polygon. The building was inside the regular polygon. Each edge of the polygon is s meters, and the height of theodolite was h centimeters. They wrote down the angle of elevation in degrees from each theodolite to the top of the building. They wanted to calculate the building’s height according to the data they measured. Can U help them.

The input consists of several test cases. The first line contains an integer T representing the number of test cases. Each test case contains two lines. The first line contains three integers, they are n, s, h, ( described in problem’s description ). The second line contains n float numbers, which are the angles of each elevation they wrote down. 3 ≤ n ≤ 100, 0 < s, h < 10 000.

The input consists of several test cases. The first line contains an integer T representing the number of test cases. Each test case contains two lines. The first line contains three integers, they are n, s, h, ( described in problem’s description ). The second line contains n float numbers, which are the angles of each elevation they wrote down. 3 ≤ n ≤ 100, 0 < s, h < 10 000.

1
3 100 100
60 60 60

101.0000

1. #include <stdio.h>
int main()
{
int n,p,t[100]={1};
for(int i=1;i<100;i++)
t =i;
while(scanf("%d",&n)&&n!=0){
if(n==1)
printf("Printing order for 1 pages:nSheet 1, front: Blank, 1n");
else {
if(n%4) p=n/4+1;
else p=n/4;
int q=4*p;
printf("Printing order for %d pages:n",n);
for(int i=0;i<p;i++){
printf("Sheet %d, front: ",i+1);
if(q>n) {printf("Blank, %dn",t[2*i+1]);}
else {printf("%d, %dn",q,t[2*i+1]);}
q–;//打印表前
printf("Sheet %d, back : ",i+1);
if(q>n) {printf("%d, Blankn",t[2*i+2]);}
else {printf("%d, %dn",t[2*i+2],q);}
q–;//打印表后
}
}
}
return 0;
}