Thursday, November 16, 2017

1042 - Bamboo COJ Problem Solution

http://coj.uci.cu/24h/submission.xhtml?id=1107168

In C++..........................

#include<iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>

//Nayeem Shahriar Joy,Applied Physics &Electronic Engineering,University of Rajshahi.

using namespace std;

#define pi 3.14

int main()

{
    cin.tie(0);

    ios::sync_with_stdio(0);

    cout<<fixed<<setprecision(1);

    double a,b,c,k,sum1=0,sum2=0;

    double n;

    int i;

    cin>>i;

    n=(double)i;

    while(i--){


    cin>>a>>b;

    sum1=a-((pow(a,2)+pow(b,2))/(2*a));

    cout<<sum1<<endl;

    sum2=sum2+sum1;

    }
    cout<<sum2/n<<endl;

    return 0;
}

No comments:

Post a Comment