UVA 10221 Java

  1. import java.util.*;
  2. import static java.lang.System.*;
  3.  
  4. public class main{
  5. public static void main(String[] args) {
  6. Scanner sc=new Scanner(System.in);
  7. int r = 6440;
  8. while(sc.hasNextInt())
  9. {
  10. double s = (double)sc.nextInt();
  11. double a = (double)sc.nextInt();
  12. String str = sc.next();
  13. if(str.equals("deg"))
  14. a = Math.min(360-a, a);
  15. else
  16. a /= 60;
  17. double arc= 2*Math.PI*(s+r)*a/360;
  18. double chord = Math.sqrt(2*Math.pow(s+r, 2)*(1-Math.cos(a*Math.PI/180)));
  19. System.out.printf("%.6f %.6f\r\n", arc, chord);
  20. }
  21. }
  22. };
  23.  

留言

這個網誌中的熱門文章

C# 井字遊戲