Skip to content

Instantly share code, notes, and snippets.

@mojaie
Created December 5, 2011 07:33
Show Gist options
  • Save mojaie/1432719 to your computer and use it in GitHub Desktop.
Save mojaie/1432719 to your computer and use it in GitHub Desktop.
AOJ:0016
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
double x = 0;
double y = 0;
double a = 0;
int b = 0;
while (true) {
String str = scn.next();
String[] arr = str.split(",");
if (arr[0].equals("0") && arr[1].equals("0")) break;
a = (double)Integer.parseInt(arr[0]);
x = x + a * Math.sin(Math.toRadians(b));
y = y + a * Math.cos(Math.toRadians(b));
b = b + Integer.parseInt(arr[1]);
}
if (x >= 0) {
System.out.println((int)Math.floor(x));
} else {
System.out.println((int)Math.ceil(x));
}
if (y >= 0) {
System.out.println((int)Math.floor(y));
} else {
System.out.println((int)Math.ceil(y));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment