UVA 10221 Java

import java.util.*;
import static java.lang.System.*;

public class main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int r = 6440;
    while(sc.hasNextInt())
    {
    	double s = (double)sc.nextInt();
    	double a = (double)sc.nextInt();
    	String str = sc.next();
    	if(str.equals("deg"))
    		a = Math.min(360-a, a);
    	else
    		a /= 60;
    	double arc= 2*Math.PI*(s+r)*a/360;
    	double chord = Math.sqrt(2*Math.pow(s+r, 2)*(1-Math.cos(a*Math.PI/180)));
    	System.out.printf("%.6f %.6f\r\n", arc, chord);
    }
  }
};

留言

這個網誌中的熱門文章

UVA 11321 Java