How Cow!

There is a cow in a village. She eats as much grass as she wants. Fortunately there is a large field…

Click here to read the complete problem statement.


If you need help solving this problem, mention your approach and ask specific questions. Please avoid sharing your code and asking the Community to figure out “what’s wrong”.

My calculator says: 578 x 578 x pi = 1049555.84
But for rope length 578, your answer is 1049558.294 !
I can’t understand. Please reply.

In this problem they taken the value of pi is 3.1416

1 Like
#include<stdio.h>
int main()
{
    int n,i;
    scanf("%d",&n);
    int a[n];
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    float c=acos(-1);

    float b[n];
    for(i=0;i<n;i++){
        b[i]=c*(float)a[i]*(float)a[i];

    }

    for(i=0;i<n;i++){
        printf("%.3f\n",b[i]);
    }
    return 0;

}

why is it showing wrong ans?

I got AC for the first bunch of input . but what’s wrong with second one?
my code

    for(var i=1;i<c.length;i++)
        {
            var temp = c[i]*c[i]*3.1416+""
            console.log((temp.slice(0,temp.indexOf('.')+4)))
        }

The reason is already pointed out by @bisnu_sarkar

bisnu_sarkar

Feb 26

In this problem they taken the value of pi is 3.1416

#include <stdio.h>

int main() {

	float area;
	int T,L;
	scanf("%d",&T);

	while(T--){

		scanf("%d",&L);
		float pie;
		pie=3.1416;
		area = pie * L * L;

		printf("%.3f",area);

	}
	return 0;
}

what is the problem??

You seem to have forgooten to print newline (‘\n’)

pi=3.1416 diye korlei ac hbe
kintu acos(-1) dile wa

#include<bits/stdc++.h>
#include <iomanip>
#include<iostream>

#define PI 3.1416

using namespace std;

int main(){
    int t;
    cin >> t;
    float n[t], area[t];
    for(int i=0; i<t; i++){
        cin >> n[i];
    }

    for(int i=0; i<t; i++){
        area[i] = PI * n[i] * n[i];
    }

    for(int i=0; i<t; i++){
        cout << fixed << showpoint;
        cout << setprecision(3);
        cout << area[i] << endl;
    }
    return 0;
}
```what is wrong in my code ?
it's saying wrong answer

Try taking double instead of float.

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define max_3(a,b,c)    max(a, max(b,c))
#define pi              2*acos(0.0)
int main()
{
float t,n,c=3.1415991188,d;
cin>>t;
while(t--){
    cin>>n;
    d=c*pow(n,2);
    printf("%.3f\n",d);
}
}

but its show wrong ans

T=int(input())
for x in range(1,T+1):
L=int(input())
a=3.1416LL
print(round(a,3))

why its says wrong answer?

the problem was with the value of pi. pi is a rational number. google shows 3.14159265359 as the value of pi. but gives wrong answer. So I performed a simple trick. to check the value of pi, perform 1049558.294/(578*578) and you will get pi equal 3.1415999988. Done.

But, if I use this value, my answer comes 1049558.250…

so I’m getting a wrong answer…