Problem:
 Score : 300 points    Problem Statement You are given an integer N .  Find a triple of positive integers h , n and w such that 4/N = 1/h + 1/n + 1/w .  If there are multiple solutions, any of them will be accepted.      Constraints  It is guaranteed that, for the given integer N , there exists a solution such that h,n,w \leq 3500 .         Inputs Input is given from Standard Input in the following format:  N       Outputs Print a triple of positive integers h , n and w that satisfies the condition, in the following format:  h  n  w         Sample Input 1 2      Sample Output 1 1 2 2  4/2 = 1/1 + 1/2 + 1/2 .       Sample Input 2 3485      Sample Output 2 872 1012974 1539173474040  It is allowed to use an integer exceeding 3500 in a solution.       Sample Input 3 4664      Sample Output 3 3498 3498 3498

Solution (Python):


import math

nyu = raw_input()
nyu = int(nyu)

h = 0
n = 0
w = 0

if nyu % 2 == 0:
    h = nyu
    n = nyu
    w = nyu / 2

elif nyu % 4 == 1:
    h = nyu / 4.0
    h = math.ceil(h)
    h = int(h)
    i = 0
    status = 0
    while 1:
        x = nyu*h
        y = 4*i+3
        for j in range(y/2):
            if j == 0:
                if x % y == 0:
                    n = x*2/y
                    w = x*2/y
                    status = 1
                    break
            else:
                if x % (j*(y-j)) == 0:
                    n = x/(y-j)
                    w = x/j
                    status = 1
                    break
        if status == 1:
            break
        else:
            i += 1
            h += 1

else:
    h = nyu / 4.0
    h = math.ceil(h)
    h = int(h)
    n = nyu*h*2
    w = nyu*h*2

print h,n,w

Solution (Python):

"""
http://tenka1-2017-beginner.contest.atcoder.jp/tasks/tenka1_2017_c

"""
import sys
from sys import stdin
input = stdin.readline


def main(args):
    N = int(input())

    found = False
    for h in range(1, 3500+1):
        if found:
            break
        for n in range(1, h+1):
            try:
                w = h*n / (4*h*n/N - n - h)
            except ZeroDivisionError:
                continue
            if w > 0 and w == int(w):
                print(h, n, int(w))
                found = True
                break


if __name__ == '__main__':
    main(sys.argv[1:])

Solution (Python):
N=int(input())

if N%2==0:
    print(N,N,int(N/2))
    quit()

for i in range(1,3501):
    for j in range(1,3501):
        if(4*i*j-N*(i+j)<=0):continue
        n=N*i*j/(4*i*j-N*(i+j))
        if(n==int(n)):
            print(i,j,int(n))
            quit()


quit()

Solution (Python):
N = int(input())

for h in range(1, 3501):
    for n in range(1, 3501):
        a = 4 * h * n - h * N - n * N
        if a == 0:
            break
        w = int((h * n * N) / a)
        if w > 0 and 4 / N == 1 / h + 1 / n + 1 / w:
            print(h, n, w)
            exit()

Solution (Python):
N = int(raw_input())

for h in range(1,3500):
  for w in range(h,3500):
    if (4*h*w-N*w-N*h) < 1:
      continue
    if (N*h*w % (4*h*w-N*w-N*h)) == 0:
      print h,w,(N*h*w / (4*h*w-N*w-N*h))
      exit(0)

Solution (Python):
def i1():
    return int(input())
def i2():
     return [int(i) for i in input().split()]

n=i1()
def a():
    for i in range(1,3501):
     for j in range(1,3501):
            x=4*i*j-i*n-j*n
            if x>0 and (n*j*i)%x==0:
                print(i,j,int((n*j*i)/x))
                return 0
a()

Solution (Python):
import sys
N = int(input())
for h in range(1,3501):
    for n in range(1,3501):
        if 4*n*h > N*n + N*h and (N*n*h) % (4*n*h-N*h-N*n) == 0:
            w =  (N*n*h) // (4*n*h-N*h-N*n)
            print(n,h,w)
            sys.exit()

Solution (Python):
import math

N = int(input())

if N%2 == 0:
    print(N, N, N//2)
    
else:
    flag = False
    
    for h in range(1, 3501):
        if flag == True:
            break
        
        for n in range(1, 3501):
            if flag == True:
                break
            
            if ((n*(h*4-N)-N*h) > 0) and (N*h*n)%(n*(h*4-N)-N*h) == 0:
                print(h, n, (N*h*n)//(n*(h*4-N)-N*h))
                flag = True

Solution (Python):
import sys
N = int(input())
for h in range(1, 3501):
    for n in range(1, 3501):
        if  4*h*n > N*n + N*h and  (N*h*n) % (4*h*n - N*n - N*h) == 0:
            print(str(h) + " " + str(n) + " " + str((N*h*n)//(4*h*n - N*n - N*h) ))
            sys.exit()

Solution (Python):
n=int(input())
a=1
b=1
c=1
z=0
while a<=3500:
    b=a
    if z==1:
        break
    while b<=3500:
        d=4*a*b- b*n -a*n
        if  d > 0:
            c=a*b*n/(d)
            if int(c)==c:
                print(a, b, int(c)) 
                z=1
                break 
        b+=1
    a+=1

Solution (Python):
N = int(input())
ans = [0, 0, 0]

for h in range(1, 3501):
    for n in range(1, 3501):
        if (4*n*h-N*n-N*h) <= 0:
            continue
        
        if ((N*h*n) % (4*n*h-N*n-N*h)) == 0:            
            ans[0] = h
            ans[1] = n
            ans[2] = (N*h*n) // (4*n*h-N*n-N*h)
            break
    if sum(ans) != 0:
        break

for a in ans:
    print(a, end=" ")

Solution (Python):


N = int(input())

w = 0
for h in range(1 , int(3*N/4 )+ 1) : 
    if w != 0 : 
        h -= 1
        break
    x = 4 / N - 1 / h
    if x <= 0 : continue
    for n in range(1 , int(2/(4/N - 1/h)) + 1) : 
        if (4*h*n - N*n - N*h)  <= 0 : continue
        if (N*h*n) % (4*h*n - N*n - N*h)  == 0 : 
            w = int((N*h*n) / (4*h*n - N*n - N*h) )
            break
        
print(h ,n,w)

Solution (Python):
N=int(input())
for h in range(N//4+1,3501):
    for w in range((N*h)//(4*h-N)+1,3501):
        if N*w*h%(4*h*w-N*h-N*w)==0:
            d=N*w*h//(4*h*w-N*h-N*w)
            print('{} {} {}'.format(h,w,d))
            break
    else:
        continue
    break

Solution (Python):
n = int(input())

def solve(n):
	for x in range(1, 3501):
		nx = n * x
		for y in range(x, 3501):
			
			
			
			
			nxy = nx * y
			den = 4*x*y - n*y -nx
			if (den > 0 and nxy % den == 0 and nxy//den > 0):
				print(x, y, nxy//den)
				return

solve(n)

Solution (Python):
import sys
N = int(input())
for h in range(1,3501):
    for n in range(h,3501):
        if (4*h*n - N*n - N*h) > 0:
            w = N*h*n//(4*h*n - N*n - N*h)
        else: continue
    
        if w != 0 and 4/N == (1/h + 1/n + 1/w):
            print(h, n, w)
            sys.exit()

Solution (Python):
N = int(input())

h_upper = int(0.75*N)
for h in range(h_upper, 0, -1):
    tmp = int(2/(4/N-1/h))
    for n in range(tmp,0,-1):
        if 4*h*n-N*(h+n)>0 and (N*h*n)%(4*h*n-N*(h+n)) == 0 :
            print(h,n,(N*h*n)//(4*h*n-N*(h+n)))
            break
    else:
        continue
    break