12578 - 10:6:2

All about problems in Volume 125. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Nut_Boltu
New poster
Posts: 10
Joined: Wed Dec 12, 2012 7:47 pm

12578 - 10:6:2

Post by Nut_Boltu »

i m getting WA!!!.
plz Help.

#include<cstdio>
#include<cmath>
int main()
{
int T,L;
double redArea,greenArea;
scanf("%d",&T);
while(T--)
{
scanf("%d",&L);
int r=L/5;
int W = L*6/10;
redArea=acos(-1)*pow(r,2);
greenArea=L*W-redArea;
printf("%.2lf %.2lf\n",redArea,greenArea);
}

return 0;
}
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 12578 - 10:6:2

Post by brianfry713 »

Think about what your code is doing when L is not a multiple of 5.
Check input and AC output for thousands of problems on uDebug!
Nut_Boltu
New poster
Posts: 10
Joined: Wed Dec 12, 2012 7:47 pm

Re: 12578 - 10:6:2

Post by Nut_Boltu »

thanks.... ACC. :D
alimbubt
New poster
Posts: 39
Joined: Tue Aug 07, 2012 10:40 pm
Location: BUBT,Dhaka, Bangladesh
Contact:

Re: 12578 - 10:6:2

Post by alimbubt »

Input:

Code: Select all

10
33
10
20
30
40
50
60
70
80
97
Output:

Code: Select all

136.85 516.55
12.57 47.43
50.27 189.73
113.10 426.90
201.06 758.94
314.16 1185.84
452.39 1707.61
615.75 2324.25
804.25 3035.75
1182.37 4463.03
Give me six hours to chop down a tree and I will spend the first four sharpening the axe...(BUBT ILLUSION)
http://uhunt.felix-halim.net/id/155497
http://onlyprogramming.wordpress.com/
gr81
New poster
Posts: 46
Joined: Wed Sep 26, 2012 7:52 pm

Re: 12578 - 10:6:2

Post by gr81 »

really stuck at stupid problem....my code is at http://ideone.com/9fSszm
please help.
lbv
Experienced poster
Posts: 128
Joined: Tue Nov 29, 2011 8:40 am

Re: 12578 - 10:6:2

Post by lbv »

gr81 wrote:really stuck at stupid problem....my code is at http://ideone.com/9fSszm
please help.
Use double variables, instead of floats. Check for example:

Input

Code: Select all

2
1000
775
Output

Code: Select all

125663.71 474336.29
75476.76 284898.24
gr81
New poster
Posts: 46
Joined: Wed Sep 26, 2012 7:52 pm

Re: 12578 - 10:6:2

Post by gr81 »

thanks, never thought it will screw me like this.
a.a.tanim
New poster
Posts: 1
Joined: Sat Jun 01, 2013 2:44 am

12578 - 10:6:2

Post by a.a.tanim »

i m getting WA!!!.
plz Help.



#include<stdio.h>
#include<math.h>
#define PI acos(-1)
int main()
{
double a,r;
unsigned n,i,l;
scanf("%u",&n);
for(i=1;i<=n;i++)
{
scanf("%u",&l);
r=PI*(l/5)*(l/5);
a=(6*(l*l))/10;
printf("%.2lf\t%.2lf\n",r,a-r);
}
return 0;
}
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 12578

Post by brianfry713 »

Think about what your code is doing when L is not a multiple of 5.
Check input and AC output for thousands of problems on uDebug!
mpmohi
New poster
Posts: 13
Joined: Wed Feb 26, 2014 10:15 pm

12578 can you find it's bug..?

Post by mpmohi »

I just can't see the problem of this code ....can you :(

Code: Select all

Got the solution 
Last edited by mpmohi on Sat Nov 22, 2014 10:26 pm, edited 1 time in total.
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 12578 can you find it's bug..?

Post by brianfry713 »

#include <math.h>
try using M_PI instead of your pi constant
Check input and AC output for thousands of problems on uDebug!
Shahidul.CSE
Experienced poster
Posts: 148
Joined: Sun Jul 13, 2014 4:32 am
Location: Rangpur, Bangladesh

12578 - 10:6:2

Post by Shahidul.CSE »

Why WA?

Code: Select all

Removed after Accepted
Last edited by Shahidul.CSE on Fri Jul 25, 2014 7:53 pm, edited 1 time in total.
Md. Shahidul Islam
Dept. of CSE at Begum Rokeya University, Rangpur, Bangladesh
UVa id: http://uhunt.felix-halim.net/id/438420
My facebook account,
Email me: shahidul.cse.brur@gmail.com
lighted
Guru
Posts: 587
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

Re: 12578 - 10:6:2

Post by lighted »

Your code is accepted code. :)
Problems with copy/paste? :)
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman
Shahidul.CSE
Experienced poster
Posts: 148
Joined: Sun Jul 13, 2014 4:32 am
Location: Rangpur, Bangladesh

Re: 12578 - 10:6:2

Post by Shahidul.CSE »

Thank you. Accepted!
Md. Shahidul Islam
Dept. of CSE at Begum Rokeya University, Rangpur, Bangladesh
UVa id: http://uhunt.felix-halim.net/id/438420
My facebook account,
Email me: shahidul.cse.brur@gmail.com
sabbir25112
New poster
Posts: 1
Joined: Thu Oct 02, 2014 8:54 pm

12578 10:6:2

Post by sabbir25112 »

What's the problem with my code.?? why it's not accepted.
anyone can help plz.

Code: Select all

#include<stdio.h>
#include<math.h>
#define PI acos(-1)
int main()
{
    int test,i;
    float l,w,r;
    while(scanf("%d",&test)==1)
    {
        for(i=1;i<=test;i++)
        {
            scanf("%f",&l);
            w = 0.6*l;
            r = l/5;
            printf("%.2f %.2f\n",PI*r*r,(l*w)-(PI*r*r));
        }
        }
    return 0;
}
Last edited by brianfry713 on Thu Oct 30, 2014 9:13 pm, edited 1 time in total.
Reason: Added code blocks
Post Reply

Return to “Volume 125 (12500-12599)”