import sys from math import sqrt ceil def process_input int ceil sqrt

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
import sys
from math import sqrt, ceil
def process_input(N):
n = int(ceil((1 + sqrt(1+8*N))/2 - 1))
num = int(N - ((n-1)*(n)/2))
if n % 2: # direction - up
row, col = n-num+1, num
else: # direction - down
col, row = n-num+1, num
return "/".join(map(str,[row, col]))
for input in open('test.in').readlines():
print 'TERM %s IS %s' % (input.strip(), process_input(int(input)))