Problem:
Treasure Hunt When a boy was cleaning up after his grand father passing, he found an old paper:     In addition, other side of the paper says that "go ahead a number of steps equivalent to the first integer, and turn clockwise by degrees equivalent to the second integer".  His grand mother says that Sanbonmatsu was standing at the center of town. However, now buildings are crammed side by side and people can not walk along exactly what the paper says in. Your task is to write a program which hunts for the treature on the paper.  For simplicity, 1 step is equivalent to 1 meter. Input consists of several pairs of two integers d (the first integer) and t (the second integer) separated by a comma. Input ends with "0, 0". Your program should print the coordinate ( x , y ) of the end point. There is the treature where x meters to the east and y meters to the north from the center of town.  You can assume that d ≤ 100 and -180 ≤ t ≤ 180.  Input  A sequence of pairs of integers d and t which end with " 0,0 ".  Output  Print the integer portion of x and y in a line respectively.  Sample Input  56,65
97,54
64,-4
55,76
42,-27
43,80
87,-86
55,-6
89,34
95,5
0,0  Output for the Sample Input  171
-302

Solution (Python):
import math
x, y = 0, 0
angle = math.pi / 2
while True:
  d, a = map(int, input().split(","))
  if (d, a) == (0, 0):
    break
  x += math.cos(angle) * d
  y += math.sin(angle) * d
  angle -= a * math.pi / 180
print(int(x), int(y), sep="\n")

Solution (Python):
import math
import cmath

coordinates = 0
ang = 90
while True:
    line = list(map(float, input().split(",")))
    if line[0] == 0 and line[1] == 0:
        break

    coordinates += cmath.rect(line[0], math.radians(ang))
    ang -= line[1]

print(int(coordinates.real))
print(int(coordinates.imag))

Solution (Python):
import math

x, y = 0, 0
angle = 90

while True:
  line = map(int, raw_input().split(','))
  if line[0] == 0 and line[1] == 0: break
  radian = math.radians(angle)
  x += math.cos(radian) * line[0]
  y += math.sin(radian) * line[0]
  angle -= line[1]

print(int(x))
print(int(y))

Solution (Python):
import math
x = 0
y = 0
degree = 0
while(True):
    a = map(int, raw_input().split(","))
    if(a[0] == 0 and a[1] == 0):
        break
    x += a[0] * math.sin(math.radians(degree))
    y += a[0] * math.cos(math.radians(degree))
    degree += a[1]
print(int(x))
print(int(y))

Solution (Python):




import sys
import math

def move(point,n,arg):
  return [ point[0]+n*arg[0], point[1]+n*arg[1] ]

theta = 90
p = [0.0,0.0]
for s in sys.stdin:
  d = map(int , s.split(","))
  arg = [ math.cos(theta*math.pi/180), math.sin(theta*math.pi/180) ]
  p = move(p,d[0],arg)
  theta -= d[1]
  if d == [0,0]:
    for e in p:
      print int(e)

Solution (Python):




import math

degree = 90
x = 0
y = 0

while True:
    a, b = map(int, input().split(','))
    if a is 0 and b is 0: break
    x += a * math.cos(math.radians(degree))
    y += a * math.sin(math.radians(degree))
    degree -= b
    if degree > 360:
        degree -= 360
    elif degree < 0:
        degree += 360
print(int(x))
print(int(y))

Solution (Python):
import sys
f = sys.stdin
import math, cmath

direction = 1j
location = 0 + 0j
while True:
    step, degrees = map(int, f.readline().split(','))
    location += direction * step
    direction *= cmath.rect(1, math.radians(-degrees))
    if step == 0:
        break
print(int(location.real))
print(int(location.imag))

Solution (Python):
import math
now_r=0
now_x=0
now_y=0

while True:
    n,r=map(int,raw_input().split(","))
    if n==0 and r==0:
        break
    now_x+=n*math.sin((now_r/180.0)*math.pi)
    now_y+=n*math.cos((now_r/180.0)*math.pi)
    now_r+=r
print int(now_x)
print int(now_y)

Solution (Python):
import math
x=0
y=0
angle=0
while True:
    r,c=map(int, input().split(","))
    if r == c == 0:
        break

    y += r*math.cos(angle)
    x += r*math.sin(angle)
    angle -= c*math.pi/180


print(int(-x))
print(int(y))

Solution (Python):
import sys,math
x=y=r=0
m=3.14/180
for l in sys.stdin:
	h,w=map(int,l.split(","))
	x+=h*math.sin(r*m)
	y+=h*math.cos(r*m)
	r+=w
print"%d\n%d"%(x,y)

Solution (Python):
import sys,math
x=y=r=0
m=3.14/180
for l in sys.stdin:
	h,w=map(int,l.split(","))
	x+=h*math.sin(r*m)
	y+=h*math.cos(r*m)
	r+=w
print"%d\n%d"%(x,y)

Solution (Python):
from decimal import Decimal
import math

def walk(x, y, distance, angle, next_angle):
    radian = math.radians(angle)
    _x = Decimal(distance * math.cos(radian) + x)
    x = round(_x, 6)
    _y = Decimal(distance * math.sin(radian) + y)
    y = round(_y, 6)
    angle = angle - next_angle
    return x, y, angle
    
x = 0
y = 0
angle = 90
while True:
    input_line = raw_input()
    distance = int(input_line.split(',')[0])
    next_angle = int(input_line.split(',')[1])
    if distance == 0 and next_angle == 0: break
    x, y, angle = walk(x, y, distance, angle, next_angle)
print int(x)
print int(y)

Solution (Python):



import sys
import math

gx = 0
gy = 0
th = 90

for s in sys.stdin:
    x, rot = map(int, s.split(','))
    gx += x * math.cos(th/180*math.pi)
    gy += x * math.sin(th/180*math.pi)
    th -= rot

print(int(gx))
print(int(gy))

Solution (Python):


def main():
    import math
    LIST=[0,0,math.radians(90)]
    while True:
        a,b=map(float,input().split(","))
        if a==0 and b==0:
            break
        else:
            b=math.radians(b)
            LIST[0]+=a*math.sin(LIST[2])
            LIST[1]+=a*math.cos(LIST[2])
            LIST[2]-=b

    print(int(LIST[1]))
    print(int(LIST[0]))
    
if __name__ == '__main__':
    main()

Solution (Python):
import math
x,y,r = 0,0,90
while True:
  m,n = map(int,input().split(','))
  if (m,n) == (0,0):
    break
  y += m * math.sin(math.radians(r))
  x += m * math.cos(math.radians(r))
  r -= n
print(int(x))
print(int(y))

Solution (Python):
x = 0
y = 0
an = 0
from math import *
PI = 3.1415926535898
while True:
	try:
		st, ag = map(float, raw_input().strip().split(','))
		if st == 0 and ag == 0:
			print int(x)
			print int(y)
		else:
			x += st*sin(an*PI/180)
			y += st*cos(an*PI/180)
			an += ag
	except EOFError:
		break

Solution (Python):

import math as m
x,y,d=0,0,90
while True:
    r,t=map(int,input().split(","))
    if (r,t)==(0,0):
        break
    x+=r*m.cos(m.radians(d))
    y+=r*m.sin(m.radians(d))
    d-=t
print(int(x))
print(int(y))

Solution (Python):
import math

x, y, r = 0, 0, 90
while True:
    d, t = map(float, input().split(","))
    if d == t == 0:
        break
    x += d * math.cos(math.radians(r))
    y += d * math.sin(math.radians(r))
    r -= t
print(int(x))
print(int(y))

Solution (Python):
import sys
import math
def sign(x):
    if x>=0:
        return 1.0
    else:
        return -1.0

pi = math.pi
deg = 0.0
pos_x = 0.0
pos_y = 0.0

lines = sys.stdin.readlines()
for line in lines:
    line = line.split(",")
    inp = []
    for i in line:
        inp.append(int(i))
    if inp[0]>0:
        dist = inp[0]
        pos_x += dist*math.sin(deg/180*pi)
        pos_y += dist*math.cos(deg/180*pi)
        deg += inp[1]
    else:
        print ("%d" % (sign(pos_x)*math.floor(math.fabs(pos_x))))
        print ("%d" % (sign(pos_y)*math.floor(math.fabs(pos_y))))

Solution (Python):


import math
def step(n, x, y, theta):
    x += n*math.sin(theta)
    y += n*math.cos(theta)
    return x, y
    
n, m = 100, 100
x, y, theta = 0.0, 0.0, 0.0
while n != 0 and m != 0:
    n, m = map(int, raw_input().split(","))
    m = (m * math.pi)/180
    x, y = step(n, x, y, theta)
    theta = (m + theta)
print int(x)
print int(y)

Solution (Python):
from math import *
l2,angle2 = map(int,raw_input().split(","))
x_now = 0
y_now = l2
angle_now = 0
while True:
    l1 = l2
    angle1 = angle2
    if l1==0 and angle1==0:
        break
    l2,angle2 = map(int,raw_input().split(","))
    angle_now += angle1
    rad = radians(angle_now)
    x = l2*sin(rad)
    y = l2*cos(rad)
    x_now += x
    y_now += y
print int(x_now)
print int(y_now)

Solution (Python):
from math import sin, cos
from math import radians as rad
x, y, t = 0, 0, 0
while(1):
    a, b = map(int,input().split(','))
    if (a == b == 0): break;
    x += a * sin(rad(t))
    y += a * cos(rad(t))
    t += b
print(int(x))
print(int(y))

Solution (Python):
import math
 
x, y ,angle = 0, 0, 90
while True:
  line = map(int, raw_input().split(','))
  if line[0] == 0 and line[1] == 0: break
  radian = math.radians(angle)
  x += math.cos(radian) * line[0]
  y += math.sin(radian) * line[0]
  angle -= line[1]
 
print(int(x))
print(int(y))

Solution (Python):


import math

x = y = 0
tsum = 90
while True:
    d, t = map(int, raw_input().split(','))
    if d == t == 0:
        break
    x += math.cos(math.radians(tsum))*d
    y += math.sin(math.radians(tsum))*d
    tsum -= t
print int(x)
print int(y)

Solution (Python):
import math
x = 0
y = 0
r = 90
while True:
    d,t=map(int, input().split(','))
    if d==0 and t==0:
        print(int(x),int(y),sep='\n')
        exit()
    x += math.cos(math.radians(r)) * d
    y += math.sin(math.radians(r)) * d
    r -= t

Solution (Python):
import math
x = 0
y = 0
tt = 0
while True:
    d, t = map(float, input().split(','))
    y += d * math.cos(tt / 180 * math.pi)
    x += d * math.sin(tt / 180 * math.pi)
    tt += t
    if d == t ==0:
        break

print(int(x))
print(int(y))

Solution (Python):
import math, cmath

D = 90
p = complex(0, 0)
while True:
    r, d = map(float, input().split(','))
    if r == d == 0:
        print(int(p.real))
        print(int(p.imag))
        exit()

    p += cmath.rect(r, math.radians(D))
    D -= d

Solution (Python):
import sys
import itertools
import math

curdeg = 0
xstep = 0
ystep = 0
for line in sys.stdin.readlines():
    step, deg = map(int, line.split(","))
    xstep += step * math.cos(math.pi * curdeg / 180)
    ystep += step * math.sin(math.pi * curdeg / 180)
    curdeg += deg 

print(int(ystep))
print(int(xstep))

Solution (Python):
import math

res_x, res_y = 0, 0
r = 90
while 1:
    x, y = list(map(int, input().split(',')))
    if x == 0 and y == 0:
        break
    r2 = math.radians(r)
    res_x += x * math.cos(r2)
    res_y += x * math.sin(r2)
    r = r - y

print(int(res_x))
print(int(res_y))

Solution (Python):
import math

def calc(x, y, r, d, nd):
	x = x + r * math.cos(math.radians(d))
	y = y + r * math.sin(math.radians(d))
	d -= nd
	return x, y, d

x = y = 0
d = 90

while True:
	r, nd = map(int, input().split(","))
	if r == nd == 0: break
	x, y, d = calc(x, y, r, d, nd)

print(int(x))
print(int(y))

Solution (Python):
import math

x, y = 0.0, 0.0
theta = 0.0
while True:
	d, t = [eval(num) for num in input().split(',')]
	if d == 0 and t == 0:
		break
	x += d * math.sin(theta)
	y += d * math.cos(theta)
	theta += t * math.pi / 180.0
print(int(x))
print(int(y))

Solution (Python):
import math

x, y, angle = 0, 0, 90

while True:

  d, a = map(int, raw_input().split(","))

  if d == 0 and a == 0:
    break

  x += math.cos(math.radians(angle)) * d
  y += math.sin(math.radians(angle)) * d

  angle -= a

print int(x)
print int(y)

Solution (Python):
import math
import sys

x, y, r = 0, 0, 90
for i in sys.stdin.readlines():
    d, a = [int(z) for z in i.split(',')]
    if d == a == 0:
        break
    x += d * math.cos(math.radians(r))
    y += d * math.sin(math.radians(r))
    r -= a

print(int(x))
print(int(y))

Solution (Python):
import math
x = y = 0
angle = 90
while True:
    d, a = map(int, input().split(','))
    if d == a == 0:
        break
    x += d * math.cos(math.radians(angle))
    y += d * math.sin(math.radians(angle))
    angle -= a
print(int(x))
print(int(y))

Solution (Python):
from math import *

x , y = 0, 0
rad = radians(90)
while 1:
    d, t = map(int, raw_input().split(','))
    if d == 0: break
    x = x + cos(rad) * d
    y = y + sin(rad) * d
    rad -= radians(t)
print int(x)
print int(y)

Solution (Python):
from math import cos, sin, radians

pos = [0, 0]
b1 = 0
angle = 0
while True:
    a, b = map(int, raw_input().split(','))
    if a == 0 and b == 0:
        break
    rad = radians(angle)
    pos[0] += -sin(rad)*a
    pos[1] += cos(rad)*a
    angle += b
print -int(pos[0])
print int(pos[1])

Solution (Python):
import math
Tre = []
num = 0
while True:
    li = list(map(int,input().split(",")))
    if li == [0,0]:
        break
    Tre.append(li)
    num += 1
x,y = 0,0
deg = 90
for i in range(num):
    x,y = x + Tre[i][0]*math.cos(math.pi*deg/180),y + Tre[i][0]*math.sin(math.pi*deg/180)
    deg = deg - Tre[i][1]
print(int(x))
print(int(y))

Solution (Python):
from math import sin,cos,pi
x = 0
y = 0
ca = 90
while True:
    d, a = list(map(int, input().split(",")))
    if d or a:
        x += d*cos(ca*pi/180)
        y += d*sin(ca*pi/180)
        ca -= a
    else:
        break

print(int(x))
print(int(y))

Solution (Python):
from math import radians, cos, sin


if __name__ == '__main__':
    
    directions = []
    while True:
        distance, rotation = [int(x) for x in input().strip().split(',')]
        if distance == 0 and rotation == 0:
            break
        else:
            directions.append((distance, rotation))

    
    my_x = 0
    my_y = 0
    my_d = 90
    for d in directions:
        my_x += d[0] * cos(radians(my_d))
        my_y += d[0] * sin(radians(my_d))
        my_d -= d[1]

    
    print('{0}\n{1}'.format(int(my_x), int(my_y)))

Solution (Python):
from math import *
coordinate=[0,0]
degree = 0
while True:
  dist,delta_degree = list(map(int,input().split(",")))
  if [dist,delta_degree]==[0,0]:
    break
  coordinate[0] += dist*sin(degree*pi/180)
  coordinate[1] += dist*cos(degree*pi/180)
  degree += delta_degree
for c in coordinate:
  print(int(c))

Solution (Python):
import math

x=0
y=0
deg=0
while(1):
    [a,b]=map(int,raw_input().split(','))
    if a==0 and b==0:
        print int(x)
        print int(y)
        break
    else:
        x+=a*math.sin(deg*math.pi/180)
        y+=a*math.cos(deg*math.pi/180)
        deg+=b

Solution (Python):

import math

def walk(d,angle):
    x = d*math.cos(angle)
    y = d*math.sin(angle)
    p = [x,y]
    return p

x,y,angle = 0,0,90
while True:
    d, a = map(int, input().split(","))
    p = walk(d,math.radians(angle))
    x += p[0]
    y += p[1]
    angle -= a
    if d == a == 0:
        break

print(int(x))
print(int(y))

Solution (Python):
from math import *
def rad(n):
    return n * pi / 180

x, y = 0, 0
na = 90
while True:
    d, a = map(int, input().split(","))
    if d == a == 0:
        print(int(x))
        print(int(y))
        break
    x += cos(rad(na)) * d
    y += sin(rad(na)) * d
    na -= a

Solution (Python):
from math import pi,sin,cos
_x=_y=a=0
while 1:
    x,y=map(int,input().split(','))
    if x==y==0:break
    r=a*pi/180
    _x+=x*sin(r)
    _y+=x*cos(r)
    a+=y
print(*map(int,[_x,_y]),sep='\n')

Solution (Python):
import math
deg = 90
x = 0.0
y = 0.0
while True:
    di,ai = map(int, input().split(','))
    if di==0 and ai==0:
        break
    x += di*math.cos(deg*math.pi/180.0)
    y += di*math.sin(deg*math.pi/180.0)
    deg -= ai

print("%d\n%d" % (x,y))

Solution (Python):
import math
x = 0.0;
y = 0.0;
a = 90.0;
while True :
    distance, angle = map(float, input().split(","))
    if distance == 0 and angle == 0: break

    radangle = math.radians(a)

    x += math.cos(radangle) * distance
    y += math.sin(radangle) * distance
    a -= angle

print(int(x))
print(int(y))

Solution (Python):
import sys
import math as mas

x,y,d=0,0,90
for t in sys.stdin:
	a,b=map(int,t.split(','))
	if a==b==0:break
	x+=a*mas.cos(mas.radians(d))
	y+=a*mas.sin(mas.radians(d))
	d-=b
print(int(x))
print(int(y))

Solution (Python):


import sys
import os
from math import sin, cos
import math

def rotate_vector(v, rad):
    x = v[0]
    y = v[1]

    new_x = cos(rad) * x - sin(rad) * y
    new_y = sin(rad) * x + cos(rad) * y
    return (new_x, new_y)

pos = [0, 0]
dir = [0, 1]
for s in sys.stdin:
    length, degree = map(int, s.split(','))

    
    pos[0] += dir[0] * length
    pos[1] += dir[1] * length

    
    rad = math.radians(degree)
    rad *= -1

    
    dir = rotate_vector(dir, rad)
print(int(pos[0]))
print(int(pos[1]))

Solution (Python):
import math
x = y = 0
theta = 90
while True:
    d, a = map(int, input().split(','))
    if d==a==0:
        break
    x += d * math.cos(theta * math.pi / 180)
    y += d * math.sin(theta * math.pi / 180)
    theta -= a
print(int(x))
print(int(y))

Solution (Python):
import math

x = 0
y = 0
alpha = 90

while True:
    a, b = map(int, input().split(','))
    if a == b == 0:
        break
    
    x += a * math.cos(alpha / 180 * math.pi)
    y += a * math.sin(alpha / 180 * math.pi)
    
    alpha -= b
    
print(int(x))
print(int(y))

Solution (Python):
import math


def main():
    p = [0, 0]
    x = math.radians(90)
    while True:
        d, angle = map(int, input().split(","))
        if d == 0 and angle == 0:
            break
        p[0] += math.cos(x) * d
        p[1] += math.sin(x) * d
        x -= math.radians(angle)
    for i in (0,1):
        p[i] = int(p[i])
    print(*p, sep="\n")


if __name__ == "__main__":
    main()

Solution (Python):
import sys, cmath, math
t = complex(0)
a = math.pi/2
for line in sys.stdin:
    l = list(map(int, line.split(",")))
    if l == [0, 0]:
        break
    t += cmath.rect(l[0], a)
    a -= l[1]*math.pi/180
print(int(t.real))
print(int(t.imag))

Solution (Python):
from math import *

x = 0
y = 0
D = []
A = []
sum_a = -90
while True:
    d, a = map(int, input().split(","))
    if a == 0 and d == 0:
        break
    else:
        D.append(d)
        A.append(a)
for i in range(len(A)):
    x = x + D[i] * cos(sum_a * pi / 180)
    y = y - D[i] * sin(sum_a * pi / 180)
    if abs(x-round(x))<10**(-7):
        x=round(x)
    if abs(y - round(y)) < 10 ** (-7):
        y=round(y)
    sum_a += A[i]
if x >= 0:
    print(floor(x))
else:
    print(floor(x)+1)
if y >= 0:
    print(floor(y))
else:
    print(floor(y)+1)

Solution (Python):
from math import sin,cos,pi

def rad(ang):
  return pi/180 * ang

x = y = 0
ang = 90

while True:
  dist, next_ang = map(int, input().split(','))
  x += dist * cos(rad(ang))
  y += dist * sin(rad(ang))
  ang += -1 * next_ang
  if dist == 0 and next_ang ==0:
    break

print(int(x))
print(int(y))

Solution (Python):
import cmath
import math

z = 0 + 0j
theta = 90
while True:
    r, phi = map(int, input().split(","))
    if r == phi == 0:
        break
    z += cmath.rect(r, math.radians(theta))
    theta = (theta - phi) % 360
print(math.trunc(z.real))
print(math.trunc(z.imag))

Solution (Python):
import math
A = math.radians(90)
aD = 90
x = y = 0
while 1:
    user = input().split(",")
    r = int(user[0])
    if r == 0 and int(user[1]) == 0:
        break
    x += r * math.cos(A)
    y += r * math.sin(A)
    aD -= int(user[1])
    A = math.radians(aD)
print(int(x))
print(int(y))

Solution (Python):


import sys, math, os


PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


x, y = 0, 0
direction = 90
while True:
    d, t = [int(_) for _ in input().split(',')]
    if d == t == 0:
        break
    angle = direction * math.pi / 180
    x += d * math.cos(angle)
    y += d * math.sin(angle)
    direction = (direction - t) % 360
    
print(int(x))
print(int(y))

Solution (Python):
import sys
import math

def TreasureHunt():
    x,y=(0.0,0.0)
    alpha=90
    
    for line in sys.stdin:
        a,b=list(map(int,line.split(',')))
        if a==0 and b==0:
            break
        
        x+=a*math.cos(alpha/180.0*math.pi)
        y+=a*math.sin(alpha/180.0*math.pi)
        alpha=(alpha-b+360)%360

    print(int(x))
    print(int(y))

        
        
            
TreasureHunt()

Solution (Python):
from math import radians, sin, cos
import sys
x, y, a = 0, 0, 0
for l in sys.stdin.readlines()[:-1]:
    d, _a = map(int, l.split(","))
    x += d * sin(radians(a))
    y += d * cos(radians(a))
    a += _a

print(int(x), "\n", int(y), sep="")

Solution (Python):
import math
x,y=(int(i) for i in input().split(','))
theta=1/2*math.pi
Ansy=0
Ansx=0
while(x!=0 or y!=0):
    Ansy=Ansy+x*math.sin(theta)
    Ansx=Ansx+x*math.cos(theta)
    theta=theta-y/180*math.pi
    x,y=(int(i) for i in input().split(','))
print(int(Ansx))
print(int(Ansy))

Solution (Python):

import math

x = 0
y = 0
direction = math.pi/2
while True:
    d, a = map(int, input().split(','))
    if d == 0 and a == 0:
        break
    x += d * math.cos(direction)
    y += d * math.sin(direction)
    direction -= a*math.pi/180
print('{0:.0f}'.format(math.modf(x)[1]))
print('{0:.0f}'.format(math.modf(y)[1]))

Solution (Python):
from math import cos, sin, pi

treasure_x, treasure_y = 0, 0
angle = pi / 2

while True:
    d, a = map(int, input().split(','))

    if d == 0 and a == 0:
        break

    treasure_x += d * cos(angle)
    treasure_y += d * sin(angle)

    angle -= a * pi / 180

print(int(treasure_x))
print(int(treasure_y))

Solution (Python):
from math import radians,sin,cos,pi
def main():
    x = 0
    y = 0
    a = 0
    while True:
        d,_a = map(int,input().split(","))
        if(d == _a == 0):
            break
        x = x + d*cos(radians(a))
        y = y + d*sin(radians(a))
        a = a + _a
    print(int(y))
    print(int(x))

if __name__ == '__main__':
    main()

Solution (Python):
import math
X = Y = a = 0
while True:
	x,y = map(int,input().split(','))
	if x == y == 0:
		break
	r = a * math.pi / 180
	X += x*math.sin(r)
	Y += x*math.cos(r)
	a+=y
print(*map(int,(X,Y)),sep='\n')

Solution (Python):
import math
x = 0.0
y = 0.0
ang = 0.5*math.pi
while True:
    d, a = map(float, input().split(","))
    if d == 0 and a == 0:
        break
    x += d*math.cos(ang)
    y += d*math.sin(ang)
    ang += math.radians(-a)
print(int(x))
print(int(y))

Solution (Python):
import math
sum_x,sum_y,dig=0,0,0
while True:
    d,a = map(int,raw_input().split(","))
    if d ==0 and a ==0:
        break
    else:
        x = d * math.sin(dig)
        y = d * math.cos(dig)
        sum_x += x
        sum_y += y
        dig = dig + math.radians(a)

print int(sum_x)
print int(sum_y)

Solution (Python):


import math

def RadToDeg(rad):
	return rad*180/math.pi

def DegToRad(deg):
	return deg*math.pi/180

deg = 90
x = 0.
y = 0.

while True:
	d, theta = map(int, raw_input().split(","))
	if d == 0 and theta == 0:
		break
	else:
		x += d * math.cos(DegToRad(deg))
		y += d * math.sin(DegToRad(deg))
		deg -= theta
print(int(x))
print(int(y))

Solution (Python):
import math

def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

N = list(get_input())
x,y = 0,0
arg = 90
for l in range(len(N)):
    d,a = [int(i) for i in N[l].split(",")]
    if d == 0 and a == 0:
        break
    x = x + d * math.cos(math.radians(arg))
    y = y + d * math.sin(math.radians(arg))
    arg = arg - a
print(math.trunc(x))
print(math.trunc(y))

Solution (Python):
import math
x = y = 0
ang = 90
while True:
    d, a = map(int, input().split(','))
    if d == a == 0:
        break
    rad = ang * math.pi / 180
    x += d * math.cos(rad)
    y += d * math.sin(rad)
    ang -= a
print(int(x))
print(int(y))

Solution (Python):
import cmath,math,sys
z=0;p=90
for e in sys.stdin:
 r,d=map(int,e.split(','))
 z+=cmath.rect(r,math.radians(p))
 p-=d
print(int(z.real),int(z.imag),sep='\n')

Solution (Python):
import cmath,math,sys
z=0;p=90
for e in sys.stdin:
 r,d=map(int,e.split(','))
 z+=cmath.rect(r,math.radians(p))
 p-=d
print(int(z.real))
print(int(z.imag))

Solution (Python):
import cmath,math,sys
z=0;p=90
for e in sys.stdin:
 r,d=map(int,e.split(','))
 z+=cmath.rect(r,math.radians(p))
 p-=d
print(int(z.real))
print(int(z.imag))

Solution (Python):
import cmath,math,sys
z=0;p=90
for e in sys.stdin:
 r,d=map(int,e.split(','))
 z+=cmath.rect(r,math.radians(p))
 p-=d
print(int(z.real),'\n',int(z.imag),sep='')

Solution (Python):
import math
x = y = n= 0
while True:
	d,a = map(int,input().split(','))
	if d == a == 0: break
	x += d*math.sin(math.radians(n))
	y += d*math.cos(math.radians(n))
	n+=a
print(*map(int,(x,y)),sep='\n')

Solution (Python):
import math
x=0
y=0
d=90
cos=lambda x:round(math.cos(math.radians(x)),10)
sin=lambda x:round(math.sin(math.radians(x)),10)

while True:
    try:h,r=[int(i) for i in input().split(",")]
    except:break
    if h==0 and r==0:break
    x+=h*cos(d)
    y+=h*sin(d)
    d+=-r
print("{0}\n{1}".format(int(x),int(y)))

Solution (Python):
import math
x = y = 0
h = math.radians(90)
while True:
    d, t = map(int, input().split(","))
    if d == t == 0:
        break
    x += d * math.cos(h)
    y += d * math.sin(h)
    h -= math.radians(t)
print(int(x))
print(int(y))

Solution (Python):
import math
X=0
Y=0
th=0
while 1:
  d,a=list(map(int,input().split(",")))
  if not a and not d:break
  Y+=d*math.cos(math.radians(th))
  X+=d*math.sin(math.radians(th))
  th+=a
print(int(X))
print(int(Y))

Solution (Python):



import math

PI = 3.1415926535897932384626433832795
M = 0.01745329251994329576923690768489
EPS = 1e-8

r, q, f = 0, 90*M, 0
while True:
	d, a = list(map(int, input().split(',')))
	if d == 0 and a == 0: break
	r2 = math.sqrt(r*r + d*d - 2*r*d*math.cos(PI - math.fabs(f)))
	if math.fabs(r) < EPS or math.fabs(r2) < EPS:
		q2 = q - f
		f = a * M
	else:
		t = math.acos((r*r + r2*r2 - d*d) / (2 * r*r2));
		if f >= 0:
			q2 = q - t
			f += a*M - t
		else:
			q2 = q + t
			f += a*M + t
	r = r2
	q = q2
print(int(r * math.cos(q)), int(r * math.sin(q)), sep='\n')

Solution (Python):
import sys
from math import *
x=0.0
y=0.0
dir=90
for line in sys.stdin:
    r,t=map(int,line.split(','))
    if r==0 and t==0:break
    x=x+r*cos(2*pi*(dir%360)/360)
    y=y+r*sin(2*pi*(dir%360)/360)
    dir+=-t
print int(x)
print int(y)

Solution (Python):
import math

x=0.0
y=0.0
d=90.0

while True:
    list = [float(i) for i in raw_input().split(",")]
    if list[0]==0 and list[1]==0:
        break
    x += list[0]*math.cos(math.radians(d))
    y += list[0]*math.sin(math.radians(d))
    d += -list[1]

for i in (x,y):
    print int(i)

Solution (Python):
from math import radians, sin, cos

def datasets():
    while True:
        ss = raw_input().split(',')
        dis = int(ss[0])
        deg = int(ss[1])
        if dis == deg == 0:
            return
        yield dis, deg


x = 0
y = 0


ang = radians(90)

for dis, deg in datasets():
    rad = radians(deg)
    x += dis * cos(ang)
    y += dis * sin(ang)
    ang -= rad
print int(x)
print int(y)

Solution (Python):
import math
nowx = 0
nowy = 0
nowa = 90
while True:
    (d,a) = [int(i) for i in raw_input().split(',')]
    if(d == a == 0):
        print int(nowx)
        print int(nowy)
        break
    else:
        nowx += math.cos(nowa / 180.0 * math.pi) * d
        nowy += math.sin(nowa / 180.0 * math.pi) * d
        nowa -= a

Solution (Python):
import math
a = 0
b = 0
r = 0
while True:
	n,m = map(int,raw_input().split(','))
	if n==0 and m==0:
		break
	a += n * math.sin(math.radians(r))
	b += n * math.cos(math.radians(r))
	r += m
print(int(a))
print(int(b))

Solution (Python):
from __future__ import (absolute_import, division, print_function,
                        unicode_literals)
from sys import stdin
from math import radians
from cmath import rect

p = 0+0j
prev_angle = radians(-90)
for line in stdin:
    m, next_angle = (int(i) for i in line.split(','))
    if not (m or next_angle):
        break
    p += rect(m, -prev_angle)
    prev_angle += radians(next_angle)
print('{}\n{}'.format(int(p.real), int(p.imag)))

Solution (Python):
import math
rad=0
x=0
y=0
while True:
    try:
        r,c=map(int,raw_input().split(','))
    except EOFError:
        break
    
    x+=math.cos(rad)*r
    y+=math.sin(rad)*r
    rad+=c*math.pi/180
    
print int(y)
print int(x)

Solution (Python):
import turtle
kame = turtle.Turtle()
kame.speed(0)
kame.left(90)
while True:
	x = map(int,raw_input().split(','))
	if x[0] == 0 and x[1] == 0:
		break
	else:
		kame.fd(x[0])
		kame.right(x[1])
		continue
print int(kame.xcor())
print int(kame.ycor())

Solution (Python):
'''
Created on Mar 22, 2013

@author: wukc
'''
from sys import stdin
import math

x,y=0,0
t=math.radians(90)
for l in stdin:
    r,d=map(int,l.split(","))
    if (r,d)==(0,0): break
    x+=r*math.cos(t)
    y+=r*math.sin(t)
    t+=math.radians(-d)    
    
print(int(x))
print(int(y))

Solution (Python):

import sys
import math


class Walker:
    def __init__(self):
        self.x = 0.0
        self.y = 0.0
        self.deg = 0.0

    def walk(self, dis):
        dis = float(dis)
        self.x += dis * math.sin(math.radians(self.deg))
        self.y += dis * math.cos(math.radians(self.deg))

    def turn(self, deg):
        self.deg += float(deg)


walker = Walker()




for line in sys.stdin:
    d = map((lambda x: int(x)), line.split(','))
    dis = d[0]
    deg = d[1]
    if dis == 0 and deg == 0:
        break
    walker.walk(dis)
    walker.turn(deg)

print int(walker.x)
print int(walker.y)

Solution (Python):
import math
pi=3.14159265358979

def radians(x):
    return 1.0*x/180*pi
    
x = 0
y = 0
theta = radians(90)

while True:
    a, b = map(float, raw_input().split(','))
    if a==0 and b==0: break
    x += a * math.cos(theta)
    y += a * math.sin(theta)
    theta += radians(-b)

print int(x)
print int(y)

Solution (Python):
import math
pi=3.14159265358979

x = 0
y = 0
theta = math.radians(90)

while True:
    a, b = map(float, raw_input().split(','))
    if a==0 and b==0: break
    x += a * math.cos(theta)
    y += a * math.sin(theta)
    theta += math.radians(-b)

print int(x)
print int(y)

Solution (Python):
import math

x = 0
y = 0
theta = math.radians(90)

while True:
    a, b = map(float, raw_input().split(','))
    if a==0 and b==0: break
    x += a * math.cos(theta)
    y += a * math.sin(theta)
    theta += math.radians(-b)

print int(x)
print int(y)

Solution (Python):
import math

x, y, angle = 0, 0, 0
while True:
    a, b = map(float, raw_input().split(','))
    if (a, b) == (0, 0):
        break
    x += a * math.sin(angle * (math.pi / 180))
    y += a * math.cos(angle * (math.pi / 180))
    angle += b
print int(x)
print int(y)

Solution (Python):


import math

def main():

	turtle = Turtle(0, 0, 0, 1)
	while True:
		input = raw_input()
		if input == '0,0':
			break

		args = input.strip().split(',')
		dist = int(args[0])
		degree = int(args[1])

		rad = 2 * math.pi * degree / 360.0

		turtle.move(dist)
		turtle.rotate(rad)

	print("%d" % (turtle.x))
	print("%d" % (turtle.y))

class Turtle:

	def __init__(self, x, y, vx, vy):
		self.x  = x
		self.y  = y
		self.vx = vx
		self.vy = vy
		self.normalize_velocity()

	def move(self, dist):
		self.x += self.vx * dist
		self.y += self.vy * dist

	def normalize_velocity(self):
		vx = self.vx
		vy = self.vy
		v = math.sqrt(vx * vx + vy * vy)
		self.vx = vx / v
		self.vy = vy / v

	def rotate(self, theta):
		vx = self.vx
		vy = self.vy

		self.vx = vx * math.cos(theta) + vy * math.sin(theta)
		self.vy = -vx * math.sin(theta) + vy * math.cos(theta)


main()

Solution (Python):
from math import sin, cos, radians

cl = [0, 0]
cd = 0

while True:
    o = input()
    if o == (0, 0):
        break

    cl[0] += o[0] * sin(radians(cd))
    cl[1] += o[0] * cos(radians(cd))
    cd += o[1]
    if 180 <= cd:
        cd -= 360
    elif cd <= -180:
        cd += 360

for x in cl:
    print(int(x))

Solution (Python):


import sys
from math import *

lineNumber = 0
coord = [0, 0]
theta = 0.5 * pi

for line in sys.stdin.readlines():
    lineNumber += 1

    
    List = map(float, line.strip().split(","))

    
    forward = List[0]
    d_theta = - List[1] / 180.0 * pi

    
    coord[0] += forward * cos(theta)
    coord[1] += forward * sin(theta)
    theta += d_theta

print int(coord[0])
print int(coord[1])