11152 - Colourful Flowers

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

Moderator: Board moderators

temper_3243
Experienced poster
Posts: 105
Joined: Wed May 25, 2005 7:23 am

11152 - Colourful Flowers

Post by temper_3243 »

I found the circumcircle radius and incricle radius but i am getting WA

Code: Select all

 ACC
Last edited by temper_3243 on Sun Dec 31, 2006 6:51 am, edited 1 time in total.

little joey
Guru
Posts: 1080
Joined: Thu Dec 19, 2002 7:37 pm

Post by little joey »

Never mix doubles and integers!
Declare a, b and c as doubles, and read them that way, and you'll get accepted.

Then delete your code.

Spykaj
New poster
Posts: 47
Joined: Sun May 21, 2006 12:13 pm

Post by Spykaj »

I don't agree with little joey, my variables are:

Code: Select all

int a,b,c;
double p,P,C1,C2,r,R;
and I have ACC ;]
Last edited by Spykaj on Mon Apr 09, 2007 1:33 pm, edited 1 time in total.

jan_holmes
Experienced poster
Posts: 136
Joined: Fri Apr 15, 2005 3:47 pm
Location: Singapore
Contact:

Post by jan_holmes »

I think it depends how we implement this integer to the program...

Code: Select all


int n = 5;
double ret = 0;
ret = n/2;

is different with

Code: Select all


int n = 5;
double ret = 0;
ret = n/2.0;

Sometimes we forgot with this and makes our program totally wrong... (It also happened to me many times...) :oops:
Last edited by jan_holmes on Sat Dec 30, 2006 9:42 pm, edited 1 time in total.

fpavetic
Learning poster
Posts: 51
Joined: Sat Mar 04, 2006 8:00 pm

Post by fpavetic »

there can be cases where sum of length of two sides is less than length of third side. try this case: 1 2 1000

jurajz
Learning poster
Posts: 69
Joined: Sat Sep 02, 2006 7:30 pm
Location: Slovakia

Post by jurajz »

I don't think, that's so... My AC program don't assume this. For input 1 2 1000, I have runtime error 207 (invalid floating point operation), but in judge it is OK.

emotional blind
A great helper
Posts: 383
Joined: Mon Oct 18, 2004 8:25 am
Location: Bangladesh
Contact:

Post by emotional blind »

fpavetic wrote:there can be cases where sum of length of two sides is less than length of third side. try this case: 1 2 1000
I dont think so. I got Accepted without checking this.

fpavetic
Learning poster
Posts: 51
Joined: Sat Mar 04, 2006 8:00 pm

Post by fpavetic »

emotional blind wrote:
fpavetic wrote:there can be cases where sum of length of two sides is less than length of third side. try this case: 1 2 1000
I dont think so. I got Accepted without checking this.
i got accepted after checking that :)

emotional blind
A great helper
Posts: 383
Joined: Mon Oct 18, 2004 8:25 am
Location: Bangladesh
Contact:

Post by emotional blind »

Strange :roll:
What is your outout in that case? :-?

fpavetic
Learning poster
Posts: 51
Joined: Sat Mar 04, 2006 8:00 pm

Post by fpavetic »

emotional blind wrote:Strange :roll:
What is your outout in that case? :-?
785398.1634 0.0000 0.0000

little joey
Guru
Posts: 1080
Joined: Thu Dec 19, 2002 7:37 pm

Post by little joey »

Spykaj wrote:I don't agree with little joey, my variables are:

Code: Select all

int a,b,c;
double p,P,C1,C2,r,R;
and I have ACC ;]
Well, of course you can mix them, but you have to be extra careful when you do. In temper's code:

Code: Select all

/* inradius */
      r2 =
   0.5 * sqrt (((b + c - a) * (c + a - b) * (a + b - c)) / (a + b + c));
the division is actually an integer division, which leads to an unexpected error.
If you make it a habbit never to mix variables of different types, this kind of error will not slip your attentention.
My remark was meant as an advise, not as a law :)

emotional blind
A great helper
Posts: 383
Joined: Mon Oct 18, 2004 8:25 am
Location: Bangladesh
Contact:

Post by emotional blind »

fpavetic wrote:
emotional blind wrote:Strange :roll:
What is your outout in that case? :-?
785398.1634 0.0000 0.0000
How can your input is valid??
It is totally impossible to take three point from the boundary of any circle that produce such impossible triangle.. so surely this kind of input is not there in judge data..

Thanks

temper_3243
Experienced poster
Posts: 105
Joined: Wed May 25, 2005 7:23 am

Post by temper_3243 »

Joey,
I got accepted when i changed the a,b,c's to double and read them like that.
or
But when i do 1.0 *(a+b+c) isn't it valid. I still got WA. Everywhere else double promotion takes place except, Well the test case contains a case where int overflow happens

sqrt ((a + b + c) * (b + c - a) * (c + a - b) * (a + b - c)); // typecasted to double



r2 =
0.5 * sqrt (((b + c - a) * (c + a - b) * (a + b - c)) / (1.0*(a + b + c)));

DP
Learning poster
Posts: 62
Joined: Sun Aug 13, 2006 9:15 am
Location: Bangladesh
Contact:

Post by DP »

Code: Select all

........accepted.......
Last edited by DP on Sun Dec 31, 2006 9:48 am, edited 1 time in total.

sohel
Guru
Posts: 856
Joined: Thu Jan 30, 2003 5:50 am
Location: New York

precision problem

Post by sohel »

PI = acos(-1);

Post Reply

Return to “Volume 111 (11100-11199)”