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 1341. Device

Why WA? Source here... (+)
Posted by YoD 29 May 2005 17:31
#include <stdio.h>
#include <math.h>

#define r 6400.0
#define PI 3.141592653589
#define EPS 1e-8

void norm(double &s, double &d)
{
    while (s > PI) s -= PI;
    while (s < -PI) s += PI;
    while (d > 2*PI) d -= 2*PI;
    while (d < -2*PI) d += 2*PI;
}

int main(void)
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);


    double s0, d0, sq = 0.0;
    scanf("%lf %lf %lf", &s0, &d0, &sq);
    s0 = s0*PI/180;
    d0 = d0*PI/180;
    s0 += sq/r; norm(s0, d0);
    d0 += sq/(r*cos(s0)); norm(s0, d0);
    s0 -= sq/r; norm(s0, d0);
    d0 -= sq/(r*cos(s0)); norm(s0, d0);
    printf("%.3lf\n%.3lf\n", s0*180/PI, d0*180/PI);
    return 0;
}