Solution of 12578 - 10:6:2

Problem Description
source: https://uva.onlinejudge.org/external/125/12578.html

The national flag of Bangladesh is bottle green in color and rectangular in size with the length (L) to width ratio of 10:6. It bears a red circle on the background of green. It maintains the length (L) to radius ratio of 5:1 (If the length is 10 then width should be 6 and radius should be 2). The color in the background represents the greenery of Bangladesh while the red circle symbolizes the rising sun and the sacrifice of lives in our freedom fight. 

Input 


First line of input will contain the number of test cases, T ≤ 100. Then there follows T lines, each containing a positive integer L ≤ 1000, representing length of the flag. 

Output

 For each test case output is a line with two space separated real numbers containing exactly two digits after decimal point. Two numbers represent the area of red and green portion respectively. Note: Pi is considered to be arccos(−1). 

Sample Input

 1
 10 

Sample Output 

12.57 47.43

Solution :

#include <algorithm>
#include <cstdio>
#include <cmath>
#include<stdio.h>
#define PI acos(-1)
using namespace std;

int main()
{
    int t,i;
    double l,w,r,areac, arearec;
    while(scanf("%d",&t)==1)
    {
        for(i=1;i<=t;i++)
        {
            scanf("%lf",&l);
            r=l/5;
            w=(l*6)/10;
            areac=PI*r*r;
            arearec=(l*w)-areac;
            printf("%.2lf %.2lf\n",areac,arearec);
        }
    }
    return 0;
}

No comments:

Post a Comment

Write your comment - Share Knowledge and Experience