24h購物| | PChome| 登入
2013-05-29 16:27:03| 人氣1,533| 回應0 | 上一篇 | 下一篇

[UVA][Easy] 12611 - Beautiful Flag

推薦 0 收藏 0 轉貼0 訂閱站台


  Beautiful Flag 

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 origin in 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 left, upper right, lower 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 

2
20
100

Sample Output 

Case 1:
-45 30
55 30
55 -30
-45 -30
Case 2:
-225 150
275 150
275 -150
-225 -150


Problemsetter: Towhidul Islam Talukder
Special Thanks: Anna Fariha



給定比例方式,從圓心開始繪製 孟加拉 的國旗,輸出四個角的點座標。


#include <stdio.h>

int main() {
    int t, cases = 0, r;
    scanf("%d", &t);
    while(t--) {
        scanf("%d", &r);
        int length = r*5, width = length*60/100;
        int right = length*45/100, left = length*55/100;
        printf("Case %d:\n", ++cases);
        printf("%d %d\n", -right, width/2);
        printf("%d %d\n", left, width/2);
        printf("%d %d\n", left, -width/2);
        printf("%d %d\n", -right, -width/2);
    }
    return 0;
}

台長: Morris
人氣(1,533) | 回應(0)| 推薦 (0)| 收藏 (0)| 轉寄
全站分類: 不分類 | 個人分類: UVA |
此分類下一篇:[UVA][Easy] 12626 - I ❤ Pizza
此分類上一篇:[UVA][動態支配點] 11020 - Efficient Solutions

是 (若未登入"個人新聞台帳號"則看不到回覆唷!)
* 請輸入識別碼:
請輸入圖片中算式的結果(可能為0) 
(有*為必填)
TOP
詳全文