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



Sample input:
2


Sample output:
1 2 2

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())

for i in range(int(3*n/4), 3500+1):
    for j in range(i, 3500 + 1):
        for k in range(j, 3500 + 1):
            if int(4*i*j*k / (i*j + j*k + k*i)) == n:
                print(i, j, k)
                exit()

Submission status: Wrong Answer

Solution code:
#! /usr/bin/env python3
# -*- coding: utf-8 -*-

N = int(input())

ans = 4/N

intans = int(N/4)

if intans < 1 :
	intans = 1

minVal = (3 * N) / 4
minVal = int(minVal) + 2


for h in range(intans,minVal):
	for n in range(intans,minVal):
		for w in range(intans,minVal):
			if 1/h + 1/n + 1/w == ans:
				print(str(h) + " " + str(n) + " " + str(w))
				exit(0)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Here your code !
N = int(input())

w = 0
for h in range(1 , int(3*N/4 )+ 1) : 
    print("h =" , h)
    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) : 
        print("n =" , n)
        y = x - 1/n
        if y <= 0 : continue
        if n % (x*n - 1)  == 0 : 
            w = int(n / (n*x - 1))
            break
        
print(h ,n,w)

Submission status: Wrong Answer

Solution code:
import math

num = int(input())
ans = [0,0,0]
value = 4 / num
limit = [math.ceil(num/4),0.0,0.0]
flag = 0
# print(limit)
for a in range(limit[0],limit[0]+350):
    if(flag):
        break
    remain = value - 1/a
    if remain <= 0:
        continue
    limit[1] = math.ceil(1/remain)
    for b in range(limit[1],limit[1]+350):
        # print(a,b,remain,limit)
        if(flag):
            break
        remain = value - 1/a - 1/b
        if remain <= 0:
            continue
        limit[2] = math.ceil(1/remain)
        for c in range(limit[2],limit[2]+350):
            # print(a,b,c,remain)
            if 1/a + 1/b + 1/c == value:
                print(a,b,c)
                flag=1
                break
            else:
                c+=1
        b+=1
    a+=1

Submission status: Wrong Answer

Solution code:
#! /usr/bin/env python3
# -*- coding: utf-8 -*-

N = int(input())

ans = 4/N

intans = int(N/4)

if intans < 1 :
	intans = 1

minVal = (3 * N) / 4
minVal = int(minVal) + 1


for h in range(intans,minVal):
	for n in range(intans,minVal):
		for w in range(intans,minVal):
			if 1/h + 1/n + 1/w == ans:
				print(str(h) + " " + str(n) + " " + str(w))
				exit(0)

Submission status: Wrong Answer

Solution code:
N = int(raw_input())
for n in range(max(1,N/4),3501):
 for h in range(max(1,N/4),3501):
  if (4*h*n == N*n + N*h):
   continue
  w=N*h*n / (4*h*n - N*n - N*h)
  if (w<1) or (w > 3500 ) or (int(w) != w):
   continue
  print n,h,w
  exit()

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Here your code !
N = int(input())

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

Submission status: Wrong Answer

Solution code:
#!usr/bim/python
#! -*- coding: utf-8 -*-
import math

nyu = raw_input()
nyu = int(nyu)

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

else:
    h = nyu / 4.0
    h = math.ceil(h)
    h = int(h)
    x = 4*h-nyu
    if x == 1:
        n = nyu*h*2
        w = nyu*h*2
    elif nyu % 3 == 0:
        n = nyu*h*2/3
        w = nyu*h*2/3
    else:
        n = nyu*h/2
        w = nyu*h

print h,n,w

Submission status: Wrong Answer

Solution code:
N = int(raw_input())
for n in range(1,3501):
  for h in range(1,3501):
   try:
    w = N*h*n / (4*h*n - N*n - N*h)
    if (w<1) or (int(w) != w):
     continue
   except:
    continue
   print n,h,w
   exit()

Submission status: Wrong Answer

Solution code:
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/n-1/i-1/j
        if x>0 and 1/x==int(1/x):
            print(i,j,int(1/x))
            return 0
a()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
for h in range(1, 3501):
    for w in range(1, 3501):
        b = 4*h*w - N*(h+w)
        if b == 0: continue
        a = N*h*w
        n = a//b
        r = a%b
        if r == 0 and n > 0:
            print(h, n, w)
            exit()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
for h in range(1, 3501):
  for n in range(1, 3501):
    a = N*h*n
    b = 4*h*n - N*n - N*h
    if b == 0:
      continue
    if a % b:
      continue
    if a//b < 0:
      continue
    print(h, n, a//b)
    exit()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
for h in range(1, 3501):
  for n in range(1, 3501):
    a = N*h*n
    b = 4*h*n - N*n - N*h
    if b == 0:
      continue
    if a % b:
      continue
    print(h, n, a//b)

Submission status: Time Limit Exceeded

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


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

    for h in range(1, 3501):
        for n in range(1, 3501):
            if 4 * n * h - N * n - N * h == 0:
                continue
            q, r = divmod(N * n * h, 4 * n * h - N * n - N * h)
            if r == 0 and q > 0:
                print(h, n, q)
                return


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
a = int(input())
for h in range(1, 3501):
  for n in range(1, 3501):
    for w in range(1, 3501):
      if 4/a == 1/h + 1/n + 1/w:
        print(h, n, w)
        break
    else:
        continue
    break
  else:
    continue
  break

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
for h in range(1,3501):
    for n in range(1,3501):
        if (4 * h * n - N * n - N * h) != 0 and (N * h * n) % (4 * h * n - N * n - N * h) == 0:
            if (N * h * n) // (4 * h * n - N * n - N * h) > 0:
                print("{} {} {}".format(h,n,(N * h * n) // (4 * h * n - N * n - N * h)))
                exit()

Submission status: Time Limit Exceeded

Solution code:
import math
N = int(input())
for h in range(1,3500):
    for n in range(1,3500):
        d = N*n+N*h-4*h*n
        if d!=0:
            w = N*h*n/d
            if w.is_integer(): 
                w = int(max(w,-w))
                ans = [h,n,w]
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
for a in range(n//2,3501):
 for b in range(n//2,3501):
  if 4*a*b-n*b-a*n==0:
   continue
  c=(n*a*b)/(4*a*b-n*b-a*n)
  if c==int(c) and c>=1:
    print(a,b,int(c))
    exit()

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
for h in range(1,3501):
    for n in range(1,3501):
        if 4*h*n-N*n-h*N==0:
            continue
        w=(N*h*n)/(4*h*n-N*n-h*N)
        if w==int(w) and w>=1:
            print(h,n,int(w))
            exit()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
for h in range(1,3500+1):
    for n in range(1,3500+1):
        if 4 * n * h - N * h - N * n == 0:
            continue
        w = N * h * n / (4 * n * h - N * n - N * h)
        if w > 0 and int(w) == w:
            print(h,n,int(w))
            exit()

Submission status: Time Limit Exceeded

Solution code:
# tenka1-2017-beginnerC - 4/N
# exhaustive search
def main():
    N = int(input())
    for h in range(1, 3501):
        for n in range(1, 3501):
            numerator = N * h * n
            denominator = 4 * h * n - N * n - N * h
            if denominator > 0 and numerator % denominator == 0:
                w = numerator // denominator
                print(h, n, w)
                return


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

left = []
for h in range(1,3500):
    left.append(4/N-1/h)

left.sort()

import bisect
ans = [0,0,0]
flag = 0
for n in range(1,3500):
    if flag == 1:
        break
    for w in range(1,3500):
        temp = 1/n + 1/w
        index = bisect.bisect_left(left, temp)
        if index < len(left) and left[index] == temp:
            ans[1] = n
            ans[2] = w
            flag = 1
            break

n = ans[1]
w = ans[2]
h = N*n*w // (4*n*w - N*w - N*n)

print('{} {} {}'.format(h,n,w))

Submission status: Time Limit Exceeded

Solution code:
def solve(N):
    for h in range(1, 3501):
        for n in range(1, 3501):
            d = 4*h*n - N*h - N*n
            if d == 0: continue
            w = N*h*n / d
            if 0 < w and w == int(w):
                print(h, n, int(w))
                return

N = int(input())

solve(N)

Submission status: Time Limit Exceeded

Solution code:
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)
            if w>0 and w==int(w):
                print(h,n,int(w))
                exit()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
for n in range(1, 3501):
    for w in range(1, 3501):
        denominator = 4*n*w - w*N - n*N
        numerator = n*w*N
        if denominator != 0 and numerator%denominator == 0:
            h = numerator // denominator
            if 0 < h <= 3500:
                print(h, n, w)
                break
    else:
        continue
    break

Submission status: Time Limit Exceeded

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N=INT()

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
for i in range(1,3501):
  for j in range(1,3501):
    p=4*i*j-n*i-n*j
    if p>0:
      if (n*i*j)%p==0:
        print(i,j,(n*i*j)//p)
        exit()

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
for i in range(1,3501):
  for j in range(1,3501):
    p=4*i*j-n*i-n*j
    if p>0:
      q=n*i*j
      if q%p==0:
        print(i,j,q//p)
        exit()

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
for i in range(1,3501):
  for j in range(1,3501):
    p=4*i*j-n*i-n*j
    if p>0:
      q=n*i*j
      if q%p==0:
        k=q//p
        break
  else:
    continue
  break
print(i,j,k)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
for i in range(1,3501):
  for j in range(1,3501):
    if (4*i*j-n*i-n*j)!=0:
      if (n*i*j)%(4*i*j-n*i-n*j)==0 and (n*i*j)//(4*i*j-n*i-n*j)>0:
        k=(n*i*j)//(4*i*j-n*i-n*j)
        break
  else:
    continue
  break
print(i,j,k)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
N = 4/N

for h in range(1, 3501):
    for n in range(2, 3501):
        w = (h*n*N) / (4*h*n - N*h - N*n)
        if w >= 1:
            print(h, " ", n, " ", w)
            break

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
ans = 0
r = range(3500)
if N > 2500:
	r = reversed(r)
while ans == 0: 
	for h in r:
		h = h + 1
		for n in r:
			n = n + 1
			up = 4*h*n - n*N - N*h
			down = N*h*n
			if up > 0:
				if down % up == 0:
					w = down // up
					ans = 1
					break
		if ans == 1:
			break
print(h, n , w)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
ans = 0
while ans == 0: 
	for h in range(3500):
		h = h + 1
		for n in range(3500):
			n = n + 1
			up = 4*h*n - n*N - N*h
			down = N*h*n
			if up > 0:
				if down % up == 0:
					w = down // up
					ans = 1
					break
		if ans == 1:
			break
print(h, n , w)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

for x in range(1, 3500 + 1):
    for y in range(1, 3500 + 1):
        p = n * x * y
        q = 4 * x * y - n * (x + y)
      
        if q == 0: continue

        z, r = divmod(p, q)
        
        if r == 0:
            if z > 0:
                print(x, y, z)
                exit()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
for h in range(1, 3501):
    for n in range(1, 3501):
        tmp = 4*n*h - N*n - N*h
        if tmp > 0:
            if N * h * n % tmp == 0:
                print(h, n, N * h * n // tmp)
                exit()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
for h in range(1, 3501):
    for n in range(1, 3501):
        tmp = 4*n*h - N*n - N*h
        if tmp <= 0:
            continue
        w = N * h * n / tmp
        if w % 1 == 0:
            print(h, n, int(w))
            exit()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
N = int(input())

for h in range(1, 3501):
    for n in range(1, h+1):
        if (4/N - 1/h - 1/n) == 0: continue
        w = 1 // (4/N - 1/h - 1/n)
        if 0 < w and 4/N == 1/h + 1/n + 1/w:
            print(h, n, int(w))
            sys.exit()

Submission status: Time Limit Exceeded

Solution code:
import sys
N = int(input())

for h in range(1, 3501):
    for n in range(1, 3501):
        if (4/N - 1/h - 1/n) == 0: continue
        w = 1 // (4/N - 1/h - 1/n)
        if 0 < w <= 3500 and 4/N == 1/h + 1/n + 1/w:
            print(h, n, int(w))
            sys.exit()

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
s=False
for i in range(1,3501):
    for j in range(1,3501):
        if (4*i*j-N*i-N*j)==0:
            continue
        else:
            w=(N*i*j)/(4*i*j-N*i-N*j)
            if w%1==0 and w>0:
                p=i
                q=j
                s=True
                break
            else:
                continue
    if s==True:
        break

print("{} {} {}".format(p,q,int(w)))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import itertools

N = int(input())
k = 4 / N

def f(h, n):
    hn = h * n
    b = n + h - hn * k
    if b == 0:
        return False
    if hn % b == 0:
        ret = -(hn / b)
        return ret > 0 and ret
    return False


for h, n in itertools.permutations(range(1, 3501), r=2):
    w = f(h, n)
    if w:
        print(int(w), h, n)
        exit()

Submission status: Time Limit Exceeded

Solution code:
import math
N = int(input())
ansh = 0
ansn = 0
answ =0
for h in range(3501):
    flag = False
    for n in range(3501):
        if 4*h*n-N*n-h*N == 0:
            break
        w = N*h*n/(4*h*n-N*n-h*N)
        if math.ceil(w) == math.floor(w) and w >0:
            ansh = h
            ansn = n
            answ = int(w)
            flag = True
            break
    if flag:
        break
    
print(ansh, ansn , answ)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
s=False
for i in range(1,3501):
    for j in range(1,3501):
        if (4*i*j-N*i-N*j)==0:
            continue
        else:
            w=(N*i*j)/(4*i*j-N*i-N*j)
            flag=w.is_integer()
            if flag==True and w>0:
                p=i
                q=j
                s=True
                break
            else:
                continue
    if s==True:
        break

print("{} {} {}".format(p,q,int(w)))

Submission status: Time Limit Exceeded

Solution code:
def c_4_over_n(N):
    for h in range(1, 3501):
        for n in range(1, 3501):
            # 条件式をwについて整理したときの分子と分母
            numerator = N * h * n
            denominator = 4 * h * n - N * n - N * h
            if denominator > 0 and numerator % denominator == 0:
                w = numerator // denominator
            else:
                continue
            if 1 <= w <= 3500:
                ans = '{0} {1} {2}'.format(h, n, w)
                return ans
    return None

N = int(input())
print(c_4_over_n(N))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

w = -1
flg = False
for h in range(1, 3500 + 1):
    for n in range(h, 3500 + 1):
        p = N * n * h
        q = 4 * n * h - N * (n + h)
        #print(h, n, p, q)
        if q != 0:#q == 0のとき、1/wなしで4/Nに一致するので不適（wは無限大になる）
            if p % q == 0:
                w = p // q
                if w > 0:
                    flg = True
                    break
    if flg:
        break
print(h, n, w)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
end = 0
for h in range(1, 3501):
    for n in range(1, 3501):
        a = 4*h*n-N*n-N*h
        if a <= 0:
            continue
        w1 = N*h*n / a
        w2 = N*h*n // a
        if w1 == w2:
            print(h, n, w2)
            break
            
    else:
        continue
        
    break

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
x=3500
a=1
for k in range(1,x):
    for j in range(1,x):
        a=(4*j*k - n*k - n*j)
        if a<=0: continue
        i = n*j*k / a
        if i==int(i) :
            print(int(i),j,k)
            break
    else:
        continue
    break

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
x=3500
for k in range(1,x):
    for j in range(1,x):
        if (4*j*k - n*k - n*j)!=0:
            i = n*j*k / (4*j*k - n*k - n*j)
            if i==int(i) and i>0:
                print(int(i),j,k)
                break
    else:
        continue
    break

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
N = int(input())

def solve():
    for h in range(1, 3501):
        for w in range(1, 3501):
            a = N * h * w
            b = 4 * h * w - N * h - N * w
            if b < 1:
                continue
            n = a / b
            if n == int(n):
                print(h, int(n), w)
                return

solve()

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
N = int(input())

def solve():
    for h in range(1, 3501):
        for w in range(1, 3501):
            a = N * h * w
            b = 4 * h * w - N * h - N * w
            if b >= 1:
                n, m = divmod(a, b)
                if m == 0:
                    print(h, n, w)
                    return

solve()

Submission status: Time Limit Exceeded

Solution code:
def gcd(x, y):
    while y!=0:
        x, y = y, x%y
    return x

def process():
    n = int(raw_input().strip())
    if n%2 == 0:
        print str(n)+' '+str(n)+' '+str(n>>1)
        return
    for x in xrange(max(n>>2, 1), 3501):
        for y in xrange(x, 3501):
            b = x*y/gcd(x, y)
            b = b*n/gcd(b, n)
            a = b*4/n
            a -= b/x
            a -= b/y
            r = gcd(a, b)
            a /= r
            b /= r
            if a==1:
                print str(x)+' '+str(y)+' '+str(b)
                return

process()

Submission status: Time Limit Exceeded

Solution code:
import fractions

def process():
    n = int(raw_input().strip())
    for x in xrange(1, 3501):
        for y in xrange(x, 3501):
            b = x*y/fractions.gcd(x, y)
            b = b*n/fractions.gcd(b, n)
            a = b*4/n
            a -= b/x
            a -= b/y
            r = fractions.gcd(a, b)
            a /= r
            b /= r
            if a==1:
                print str(x)+' '+str(y)+' '+str(b)
                return

process()

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
for n in range(1,3501):
    for w in range(1,3501):
        if n*(4*w-N)-N*w==0:
            continue
        if N*n*w % (n*(4*w-N)-N*w) ==0:
            h= (N*n*w) // (n*(4*w-N)-N*w)
            if h>=1:
                print(h,n,w)
                exit()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
flag = False
for i in range(1,3501):
    for j in range(1,3501):
        if((4*i*j - N*i - N*j)==0):
            break
        w = (N*i*j)/(4*i*j - N*i - N*j)
        if(w == int(w) and w > 0):
            
            w = int(w)
            h = i
            n = j
            flag = True
            break
    
    if flag:
        break

print(h,n,w)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
c=0
b=0
h=0
n=0

for h in range(3500):
    for n in range(3500):
        c= N*h*n 
        b= 4*n*h-N*n-N*h
        if b>0 and c!=0:
            if c%b ==0:
                print(h,n,int(c/b))
                exit()

Submission status: Time Limit Exceeded

Solution code:
m = int(input())
def calc(m):
    for h in range(1, 3500):
        for n in range(1, 3500):
            for w in range(1, 3500):
                if 4 * h * n * w == m * (w * n + w * h  + h * n):
                    return h, n, w
print('{0[0]} {0[1]} {0[2]}'.format(calc(m)))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
for x in range(1, 3501):
    for y in range(x, 3501):
        A = n*x*y
        B = 4*x*y - n*x - n*y
        if B > 0 and A % B == 0:
            print(x, y, A//B)
            exit()

Submission status: Time Limit Exceeded

Solution code:
def main():
    value = int(input())
    w = 0
    for i in range(0, 3500):
        for j in range(0, 3500):
            try:
                w = (value*i*j)/(4*i*j-value*j-value*i)
            except ZeroDivisionError:
                pass
            if i == 3498 and j == 3498:
                print(w)
            if w - int(w) == 0 and w > 0:
                h = j
                n = i
                break
        if w - int(w) == 0 and w > 0:
            break
    print("{} {} {}".format(h, n, int(w)))


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
w = 0
h = 0
n = 0
for i in range(1,3501):
    for j in range(i,3501):
        if 4*i*j-N*i-N*j <= 0:
            continue
        if (N*i*j)%(4*i*j-N*i-N*j) == 0:
            w = N*i*j//(4*i*j-N*i-N*j)
            h = i
            n = j
            break
print(h,n,w)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
i,j = 1,1
while i<3501 and j<3501:
    if N/i >= 4:
        i += i
        continue
    if N/j >= 4:
        j += j
        continue
    i = i//2
    j = j//2
    for x in range(i,3501):
        for y in range(j,3501):
            if (4*x*y - N*y - N*x) == 0:
                continue
            z = N*x*y/(4*x*y - N*y - N*x)
            if z == int(z) and z >= 1:
                print(x,y,int(z))
                exit()

Submission status: Time Limit Exceeded

Solution code:
class EndLoop(Exception):
    pass


def solve():
    N = int(input())

    try:
        for h in range(1, 3500):
            for n in range(1, 3500):
                if 4 * h * n - n * N - h * N == 0:
                    pass
                elif (h * n * N) % (4 * h * n - n * N - h * N) == 0 and\
                            (4 * h * n - n * N - h * N) > 0:
                    w = (h * n * N) / (4 * h * n - n * N - h * N)
                    print(h, n, int(w))
                    raise EndLoop
    except(EndLoop):
        pass


solve()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

memo={}
for h in range(1, 3501):
    for n in range(1, 3501):
        if (h,n) not in memo:
            memo[n,h] = True
            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()
        else:
            continue

Submission status: Time Limit Exceeded

Solution code:
import sys

n = int(input())
for i in range(1, 3501):
    for j in range(i, 3501):
        if 4*i*j - n*i - n*j == 0: continue
        k = n*i*j // (4*i*j - n*i - n*j)
        if k < 1: continue
        if 4*i*j*k == n*(i*j + j*k + k*i):
            print("{0} {1} {2}".format(i, j, int(k)))
            sys.exit(0)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
for a in range(1, 3501):
    for b in range(1, 3501):
        c2 = 4 * a * b - b * N - a * N
        if c2 <= 0:continue
        c1 = a * b * N
        if c1/c2 == c1//c2:
            print(a,b,c1//c2)
            exit()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
for a in range(1, 3501):
    for b in range(1, 3501):
        c1 = a * b * N
        c2 = 4 * a * b - b * N - a * N
        if c2 > 0 and c1/c2 == c1//2:
            print(a,b,c1//c2)
            exit()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
N4 = 4 / N

for h in range(1, 3501):
    for n in range(1, 3501):
        un = N * (n + h) - 4 * h * n
        un2 = -N*h*n
        if un:
            w = (un2) / (un)
            if w >= 0 and int(w) == w:
                print(n, h, int(w))
                __import__("sys").exit()

Submission status: Time Limit Exceeded

Solution code:
import sys
N=int(input())
for h in range(1,3501):
    for n in range(1,3501):
        for w in range(1,3501):
            if N==int((4*h*n*w)/((h*n+n*w+w*h))):
                print(h,n,w)
                sys.exit()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
def search(N):
    for h in range(1, 35001):
        for n in range(h, 35001):
            if (4*h*n - n*N - h*N) > 0 and h*n*N % (4*h*n - n*N - h*N) == 0:
                print(str(h), ' ', str(n), ' ', str(h*n*N // (4*h*n - n*N - h*N)))
                return 0

search(N)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
"""
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, 3500+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:])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
flag = 0
if N < 10:
    for a in range(1,3501):
        if flag == 1:
            break
        for b in range(1,1751):
            M = (4*a*b - N*a - N*b)
            C = N*a*b
            #print(M,C,C/M)
            if M < 0 :
                continue
            elif M != 0:
                if C//M == C/M:
                    c = C//M
                    print(a,b,c)
                    flag = 1
                    break
else:
    A = [i for i in range(1,3501)]
    B = [i for i in range(1,3501)]
    for a in A[::-1]:
        if flag == 1:
            break
        for b in B[::-1]:
            M = (4*a*b - N*a - N*b)
            C = N*a*b
            #print(M,C,C/M)
            if M < 0 :
                continue
            elif M != 0:
                if C//M == C/M:
                    c = C//M
                    print(a,b,c)
                    flag = 1
                    break

Submission status: Time Limit Exceeded

Solution code:
N = int(raw_input())
F = False
for h in range(1,3500):
    for n in range(1,3500):
        for w in range(1,3500):
            if 4*h*n*w == N*(n*w+h*w+h*n):
                print('{0} {1} {2}'.format(h,n,w))
                F = True
            if F:
                break
        if F:
            break
    if F:
        break

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
flag = 0
if N < 2:
    for a in range(1,3501):
        if flag == 1:
            break
        for b in range(1,1751):
            M = (4*a*b - N*a - N*b)
            C = N*a*b
            #print(M,C,C/M)
            if M < 0 :
                continue
            elif M != 0:
                if C//M == C/M:
                    c = C//M
                    print(a,b,c)
                    flag = 1
                    break
else:
    A = [i for i in range(1,3501)]
    B = [i for i in range(1,3501)]
    for a in A[::-1]:
        if flag == 1:
            break
        for b in B[::-1]:
            M = (4*a*b - N*a - N*b)
            C = N*a*b
            #print(M,C,C/M)
            if M < 0 :
                continue
            elif M != 0:
                if C//M == C/M:
                    c = C//M
                    print(a,b,c)
                    flag = 1
                    break

Submission status: Time Limit Exceeded

Solution code:
def main():
    N = int(input())
    
    #print(N)
    #print(4 / N)
    flag = False
    lim = 3501
    for i in range(1, lim):
        for j in range(1, lim):
            for k in range(1, lim):
                if( ( 4 / N ) == (1 / i ) + (1 / j) + (1 / k) ):
                    h = i
                    n = j
                    w = k
                    flag = True
                if(flag):
                    break
            if(flag):
                break
        if(flag):
            break
        
    print("{} {} {}".format(h, n, w))
                    
if __name__=="__main__":
    main()