UVa12611 - Beautiful Flag

来源:互联网 发布:概率论 知乎 编辑:程序博客网 时间:2024/05/17 07:03

Teering is a little boy. He is trying to draw the national flag of Bangladesh. Being smart he knows he has to maintain the correct ratio and measurement while drawing the flag. You know the rules of drawing the national flag, don't you? If not, no worries, Teering is here to help you:

The national flag of Bangladesh consist of a green rectangle with a red circle inside it. The ratio of the length and width of the rectangle is 100 : 60 (i.e. if the length is 100 units then the width will be 60 units). The radius of the circle is 20% of the length (i.e. if the length is 100 units then the radius of the circle will be 20 units). To get the center of the circle you need to draw a horizontal line dividing the width in equal portion and draw a vertical line dividing the length in 45 : 55 ratio (i.e. if the length of the rectangle is 100 then 45 units will be in left and 55 units will be on the right side of the line). The crossing of the two lines will be the center of the circle. Here is an illustrated picture for better understanding.

\epsfbox{p12611.eps}

Now Teering has started to draw a flag. He has already drawn the circle of radius R centered at the originin a 2D co-ordinate system. Now he needs to determine the corner of the rectangle so that he can join them to complete the flag. Can you help him?

Input 

The first line of input will contain an integer T (T < 101) denoting the number of test cases. Each of the following T lines will contain an integer R (R < 1001) each denoting the radius of the circle.

Output 

For each input output five lines. The first line will contain the case number. The following four lines will denote the upper leftupper rightlower right and lower left coordinates of the rectangle for the flag respectively. You have to print x coordinate and y coordinate separated by space in each line. You may assume that input is given in such that the corners will always be in integer coordinates. See sample input output for details.

Sample Input 

220100

Sample Output 

Case 1:-45 3055 3055 -30-45 -30Case 2:-225 150275 150275 -150-225 -150
#include <cstdio>#include <iostream>using namespace std;void solve(int);int main(){#ifndef ONLINE_JUDGE    freopen("e:\\uva_in.txt", "r", stdin);#endif    int t;    cin >> t;    for (int i = 1; i <= t; i++) {        cout << "Case " << i << ":" << endl;        int r;        cin >> r;        solve(r);    }    return 0;}void solve(int r){    double length = r * 5;    double width = length * 3 / 5;    cout.precision(0);    cout << fixed << -length * 9 / 20 << " " << fixed << width / 2 << endl;    cout << fixed << length * 11 / 20 << " " << fixed << width / 2 << endl;    cout << fixed << length * 11 / 20 << " " << fixed << -width / 2 << endl;    cout << fixed << -length * 9 / 20 << " " << fixed << -width / 2 << endl;}



0 0
原创粉丝点击