Solution | URI Online Judge | 1002 Area of a Circle

URI Online Judge | 1002

Area of a Circle

Adapted by Neilor Tonin, URI  Brazil
Timelimit: 1
The formula to calculate the area of a circumference is defined as A = π . R2. Considering to this problem that π3.14159:
Calculate the area using the formula given in the problem description.

Input

The input contains a value of floating point (double precision), that is the variable R.

Output

Present the message "A=" followed by the value of the variable, as in the example bellow, with four places after the decimal point. Use all double precision variables. Like all the problems, don't forget to print the end of line after the result, otherwise you will receive "Presentation Error".
Input SamplesOutput Samples
2.00A=12.5664
100.64A=31819.3103
150.00A=70685.7750

সল্যুশন্সঃ
#include<iostream>
#include<iomanip>
using namespace std;
main()
{
    double R;
    cin >> R;
    cout << fixed;
    cout << "A=" << setprecision(4) << 3.14159*(R*R) << endl;
    return 0;
}

আলোচনাঃ
প্রবলেমটিতে, আপনার Pi Value এর সাথে আপনার Input Value এর Square এর গুনফল চাওয়া হয়েছে।
অর্থাৎ, Input যদি 2.00 হয় আউটপুট হবে 12.5664 (3.14149*(2^2))
আরো লক্ষ্য রাখতে হবে আপনার আউটপুট কীভাবে দেখাতে বলছে।
এখানে #include<iomanip> একটি হেডার ফাইল ইউজ করা হয়েছে। যা আপনাকে Float Value এর দশমিক এর পর নির্দিষ্ট সংখ্যক মান নিয়ে সহায়তা করবে।
setprecision দিয়ে আপনি দশমিক এর পর কত ঘর নিবেন তা ফিক্সড করা হয়েছে।

Comments

Popular posts from this blog

Solution - Codeforces Problem 327B - Hungry Sequence

Solution - Timus Problem 1293. Eniya

Solution - Timus Problem 1409. Two Gangsters