题解-python-CodeForces 227A

codeforces题目,用python写

本题输入三个点坐标,考察叉积,若大于0则right,小于0则left,等于0则towards

代码:

a = raw_input().split()
b = raw_input().split()
c = raw_input().split()
xa = int(a[0])
ya = int(a[1])
xb = int(b[0])
yb = int(b[1])
xc = int(c[0])
yc = int(c[1])
x1 = xb - xa
x2 = xb - xc
y1 = yb - ya
y2 = yb - yc
res = x1 * y2 - x2 * y1
if res > 0:
    print "RIGHT"
elif res < 0:
    print "LEFT"
else:
    print "TOWARDS"

你可能感兴趣的:(codeforces)