UVa12611 - 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 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 

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
#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
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

kgduu

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值