ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1285. Thread in a Hyperspace

Samsonov Alex [USU] Geometrical question [1] // Problem 1285. Thread in a Hyperspace 5 Jan 2007 23:01
Can anybody explain me, where am I wrong?

Definitions:
ac, ab, bc - corresponding lengths
acb - angle between (ca) and (cb)

Such code:
...
acb = acos((ac*ac + bc*bc - ab*ab) / 2.0 / ac / bc);
..

gets AC.

Such code:
...
double spv(point x1, point x2, point y1, point y2){
    int i;
    double res = 0;
    for (i=1; i<=n; i++){
        res += (x2.coord[i] - x1.coord[i]) * (y2.coord[i] - y1.coord[i]);
    }
    return res;
}
...
acb = acos(spv(c,a,c,b)/ac/bc);...
...

gets WA25.

I had always thought that these two fragments must yield the same result. Why don't they?
r1d1 Re: Geometrical question // Problem 1285. Thread in a Hyperspace 20 Aug 2009 00:27
me too. If you get WA27, use type double