Problem:


Treasure Hunt

When a boy was cleaning up after his grand father passing, he found an old paper:

Stand facing to north from "Sanbonmatsu", and go according to the following steps. You will come across a treasure at the end point.

30, 10
50, -40
20, 15
.
.

-->

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



Sample input:
56,65
97,54
64,-4
55,76
42,-27
43,80
87,-86
55,-6
89,34
95,5
0,0


Sample output:
171
-302

Submission status: Accepted

Solution code:
import math

def move(dig):
    rad = math.radians(dig)
    x = math.cos(rad)
    y = math.sin(rad)
    return x,y

def run():
    x, y = 0,0
    dig = 90
    while True:
        r, d = map(int, input().split(','))
        d = -d
        if r == 0 and d == 0:
            break
        _x, _y = move(dig)
        dig += d
        x += r * _x
        y += r * _y

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

if __name__ == '__main__':
    run()

Submission status: Accepted

Solution code:
import math
x = 0
y = 0
shi = 90
while 1:
    a,b = map(int, input().split(","))
    if a == 0 and b == 0:
        break
    else:
        x += a*math.cos(math.radians(shi))
        y += a*math.sin(math.radians(shi))
        shi -= b
print(int(x))
print(int(y))

Submission status: Accepted

Solution code:
# Treasure Hunt
import math
x,y,pd = 0,0,-90
r,d = map(int, input().split(','))
while not (r == 0 and d == 0):
    x += r * math.cos(math.radians(-pd))
    y += r * math.sin(math.radians(-pd))
    pd += d
    r,d = map(int, input().split(','))
print(int(x))
print(int(y))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
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

Submission status: Runtime Error

Solution code:
import math
x=0
y=0
while True:
 r,theta=[int(i) for i in input().split()]
 if r=0 and theta=0:
  break
 theta=math.radians(theta)
 x+=r*math.cos(theta)
 y+=r*math.sin(theta)
print(x,y)

Submission status: Runtime Error

Solution code:
import math
x=0
y=0
while True:
 r,theta=[int(i) for i in input().split("/")]
 if r=0 and theta=0:
  break
 theta=math.radians(theta)
 x+=r*math.cos(theta)
 y+=r*math.sin(theta)
print(x,y)

Submission status: Runtime Error

Solution code:
import math
x=0
y=0
while True:
 r,theta=[int(i) for i in input().split("/")]
 if r=0 and theta=0:
  break
 theta=math.radians(theta)
 x+=r*math.cos(theta)
 y+=r*math.sin(theta)
print(x)
print(y)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

import sys
from math import *

lineNumber = 0
coord = [0, 0]
theta = 0.5 * pi
#for line in [ "2", "1000", "800", "9999999999", "1" ]:
for line in sys.stdin.readlines():
    lineNumber += 1

    # line exception
    if lineNumber == 1:
        continue
    
    # get data
    List = map(float, line.strip().split())

    # set data
    forward = List[0]
    d_theta = List[1] / 180.0 * pi

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

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

Submission status: Runtime Error

Solution code:
import math
x = 0
y = 0
while True:
    m, r = map(int, raw_input())
    if m == 0 and r == 0:
        break
    theta += r
    rad = theta/180*math.pi
    x += m*math.cos(rad)
    y += m*math.sin(rad)
    
print int(x)
print int(

Submission status: Runtime Error

Solution code:
import math
x = 0.0
y = 0.0
while True:
    m, r = map(int, raw_input().split())
    if m == 0 and r == 0:
        break
    theta += r
    rad = theta/180*math.pi
    x += m*math.cos(rad)
    y += m*math.sin(rad)
    
print int(x)
print int(y)

Submission status: Runtime Error

Solution code:
import math
x = 0.0
y = 0.0
while True:
    m, r = map(int, raw_input().split(","))
    if m == 0 and r == 0:
        break
    theta += r
    rad = theta/180*math.pi
    x += m*math.cos(rad)
    y += m*math.sin(rad)
    
print int(x)
print int(y)

Submission status: WA: Presentation Error

Solution code:
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\n"%(x,y)

Submission status: WA: Presentation Error

Solution code:
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), "\n", int(y))

Submission status: WA: Presentation Error

Solution code:
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\n" % (x,y))

Submission status: WA: Presentation Error

Solution code:
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),'\n',int(y))

        
        
            
TreasureHunt()

Submission status: WA: Presentation Error

Solution code:
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))