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 1030. Titanic

i'm going mad. why my program gets WA1?
Posted by TereshinVS Liceum#165 12 Feb 2010 20:35
import java.util.*;
import java.text.*;

public class zad1030
    {
        public static void main(String[] args)
            {
                double alpS1, alpS2, alpD1, alpD2, l, r=6875/2.0, a, b, c;
                String s, res, sh="0123456789";
                Scanner cin=new Scanner(System.in);
                NumberFormat f=NumberFormat.getInstance(Locale.UK);
                f.setMinimumFractionDigits(2);
                f.setMaximumFractionDigits(2);
                while (cin.hasNext())
                    {
                        cin.nextLine();
                        cin.nextLine();
                        cin.nextLine();
                        s=cin.nextLine();
                        while (sh.indexOf(s.substring(0, 1))<0)
                            {
                                s=s.substring(1);
                            }
                        a=Integer.parseInt(s.substring(0, s.indexOf("^")));
                        s=s.substring(s.indexOf("^")+1);
                        b=Integer.parseInt(s.substring(0, s.indexOf("'")));
                        s=s.substring(s.indexOf("'")+1);
                        c=Integer.parseInt(s.substring(0, s.indexOf("\"")));
                        s=s.substring(s.indexOf("\"")+1);
                        alpS1=Math.toRadians(a+b/60.0+c/3600.0);
                        if (s.substring(0, 3)==" SL") alpS1=-alpS1;
                        s=cin.nextLine();
                        while (sh.indexOf(s.substring(0, 1))<0)
                            {
                                s=s.substring(1);
                            }
                        a=Integer.parseInt(s.substring(0, s.indexOf("^")));
                        s=s.substring(s.indexOf("^")+1);
                        b=Integer.parseInt(s.substring(0, s.indexOf("'")));
                        s=s.substring(s.indexOf("'")+1);
                        c=Integer.parseInt(s.substring(0, s.indexOf("\"")));
                        s=s.substring(s.indexOf("\"")+1);
                        alpD1=Math.toRadians(a+b/60.0+c/3600.0);
                        if (s.substring(0, 3)==" WL") alpD1=-alpD1;
                        cin.nextLine();
                        s=cin.nextLine();
                        while (sh.indexOf(s.substring(0, 1))<0)
                            {
                                s=s.substring(1);
                            }
                        a=Integer.parseInt(s.substring(0, s.indexOf("^")));
                        s=s.substring(s.indexOf("^")+1);
                        b=Integer.parseInt(s.substring(0, s.indexOf("'")));
                        s=s.substring(s.indexOf("'")+1);
                        c=Integer.parseInt(s.substring(0, s.indexOf("\"")));
                        s=s.substring(s.indexOf("\"")+1);
                        alpS2=Math.toRadians(a+b/60.0+c/3600.0);
                        if (s.substring(0, 3)==" SL") alpS2=-alpS2;
                        s=cin.nextLine();
                        while (sh.indexOf(s.substring(0, 1))<0)
                            {
                                s=s.substring(1);
                            }
                        a=Integer.parseInt(s.substring(0, s.indexOf("^")));
                        s=s.substring(s.indexOf("^")+1);
                        b=Integer.parseInt(s.substring(0, s.indexOf("'")));
                        s=s.substring(s.indexOf("'")+1);
                        c=Integer.parseInt(s.substring(0, s.indexOf("\"")));
                        s=s.substring(s.indexOf("\"")+1);
                        alpD2=Math.toRadians(a+b/60.0+c/3600.0);
                        if (s.substring(0, 3)==" WL") alpD2=-alpD2;
                        l=r*Math.acos(Math.sin(alpS1)*Math.sin(alpS2)+Math.cos(alpS1)*Math.cos(alpS2)*Math.cos(alpD1-alpD2));
                        l=Math.round(l*100)/100.0;
                        res=f.format(l);
                        System.out.println("The distance to the iceberg: "+res+" miles.");
                        if (100.0-l>=0.01) System.out.println("DANGER!");
                        cin.nextLine();
                    }
            }
    }

Edited by author 12.02.2010 21:06