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: Time Limit Exceeded

Solution code:
N=int(input())
a=4/N
for h in range(1,3501):
    H=1/h
    for n in range(h,3501):
        flag=0
        if a-H-1/n-1/h<=0 and a-H-1/n-1/3500>=0:

            st,end=h,3500
            for w in [st,end]:
                B=4*h*n*w-(n*w+h*w+h*n)*N
                if B==0:
                    break
            while st!=end:
                #print(h,n,st,end)
                w=int((st+end)/2)
                if end-st==1:
                    end=w
                    st=w
                B=4*h*n*w-(n*w+h*w+h*n)*N
                if B==0:
                    flag=1
                    break
                elif B>0:
                    end=w
                else:
                    st=w

        if flag:
            break
    if flag:
        break

print(h,n,w)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
a=4/N
for h in range(1,3501):
    H=1/h
    for n in range(h,3501):
        flag=0
        if a-H-1/n-h<=0 and a-H-1/n-1/3500>=0:

            st,end=h,3500
            for w in [st,end]:
                B=4*h*n*w-(n*w+h*w+h*n)*N
                if B==0:
                    break
            while st!=end:
                #print(h,n,st,end)
                w=int((st+end)/2)
                if end-st==1:
                    end=w
                    st=w
                B=4*h*n*w-(n*w+h*w+h*n)*N
                if B==0:
                    flag=1
                    break
                elif B>0:
                    end=w
                else:
                    st=w

        if flag:
            break
    if flag:
        break

print(h,n,w)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
a=4/N
for h in range(1,3501):
    H=1/h
    for n in range(h,3501):
        flag=0
        if a-H-1/n-1<=0 and a-H-1/n-1/3500>=0:

            st,end=1,3500
            for w in [st,end]:
                B=4*h*n*w-(n*w+h*w+h*n)*N
                if B==0:
                    break
            while st!=end:
                #print(h,n,st,end)
                w=int((st+end)/2)
                if end-st==1:
                    end=w
                    st=w
                B=4*h*n*w-(n*w+h*w+h*n)*N
                if B==0:
                    flag=1
                    break
                elif B>0:
                    end=w
                else:
                    st=w

        if flag:
            break
    if flag:
        break

print(h,n,w)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
c=0
ans1=0
ans2=0
for a in range(1,3501):
    for b in range(a+1,3501):
        if 4*a*b>(b+a)*n and (a*b*n)%(4*a*b-(b+a)*n)==0:
            c=a*b*n//(4*a*b-(b+a)*n)
            ans1=a
            ans2=b
            break
lists=[ans1,ans2,c]
print(*lists)

Submission status: Time Limit Exceeded

Solution code:
# Tenka1 2017 C

from sys import stdin


def main():
    N = int(stdin.readline().rstrip())
    for h in range(1, 3501):
        for w in range(1, 3501):
            upper = N * h * w
            lower = 4 * h * w - N * w - N * h
            if lower == 0 or upper % lower != 0:
                continue

            n = int(upper / lower)
            if n > 0:
                print(h, n, w)
                return


main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:

N = int(input())

con = True
for h in range(1,3500):
    for n in range(h,3500):
        memo1 = N*h*n
        memo2 = 4*h*n-N*n-N*h
        if memo2 != 0:
            memo3 = memo1/memo2
            memo4 = memo1%memo2
            if (memo4==0) and (memo3>=1):
                print(h,n,int(memo3))
                con = False
                break
    if not(con):
        break

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
for x in range(1, 3501):
  for y in range(1, 3501):
    t = 4 * x * y - n * y - n * x
    if(t <= 0):
      continue
    if((n * x * y) % t == 0):
      print(x, y, (n * x * y) // t)
      exit(0)

Submission status: Time Limit Exceeded

Solution code:
while True:
  pass

Submission status: Time Limit Exceeded

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

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:
            w = N*h*n/(4*h*n-N*n-N*h)
            if w == int(w) and w >= 1:
                print(h, n, int(w))
                exit()

Submission status: Time Limit Exceeded

Solution code:
def cal(a,b):
    if 4*a*b-A*(a+b)>0:
        return (A*a*b)/(4*a*b-A*(a+b))
    else:
        return -1
A = int(input())
for i in range(1,3501):
    for j in range(1,3501):
        t = cal(i,j)
        if t == -1:
            continue
        if t == int(t):
            print(i,j,int(t))
            exit()

Submission status: Time Limit Exceeded

Solution code:
#C問題
N = int(input())

M = 3500
flag = 0
for k in range(1,3500):
    for h in range(1,3500):
        bunbo = 4*k*h-k*N-h*N
        bunshi = N*k*h
        if bunbo != 0 and bunshi%bunbo == 0:
            w = bunshi//bunbo
            if w >= 0:
            	print(k,h,w)
            	flag = 1
            	break
    if flag == 1:
        break

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-N*(n+h))
    if a!=0:
      w=N*h*n/a
      if w==int(w) and 0<w<10000000:
        print(h,n,int(w),sep=" ")
        exit(0)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
for h in range(1,3501):
  for n in range(1,3501):
    if 4/N-1/h-1/n!=0:
      w=1/(4/N-1/h-1/n)
      if abs(w-int(w))==0 and 0<w<10000:
        print(h,n,int(w),sep=" ")
        exit(0)

Submission status: Time Limit Exceeded

Solution code:
from fractions import Fraction
def main():
    N = int(input())
    checked = [[False for _ in range(3500)] for _ in range(3500)]
    for h in range(1, 3501):
        for n in range(1,3501):
            if checked[h-1][n-1] == False:

                checked[h-1][n-1] = True
                checked[n-1][h-1] = True
                
                a = N*h*n
                b = 4*n*h - N*n - N*h 
                if a >= b and b >  0 and a%b == 0:
                    w = Fraction(N*h*n, 4*n*h - N*n - N*h)
                    if Fraction(4, N) == Fraction(1, h) + Fraction(1, n) + Fraction(1, w):
                        print(h,n,w)
                        exit()
                else:
                    continue
            else:
                continue

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
from fractions import Fraction
def main():
    N = int(input())

    for h in range(1, 3501):
        for n in range(1,3501):
            a = N*h*n
            b = 4*n*h - N*n - N*h 
            if a >= b and b >  0 and a%b == 0:
                w = Fraction(N*h*n, 4*n*h - N*n - N*h)
                if Fraction(4, N) == Fraction(1, h) + Fraction(1, n) + Fraction(1, w):
                    print(h,n,w)
                    exit()
            else:
                continue

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
f = True
for h in range(1,3501):
  for n in range(1,3501):
    w_ = (-(h+n)/(h*n) + 4/N)
    if w_ > 0:
      w = (1/w_)
      if w%1 < 10E-8:
        print(h,n,int(w))
        f = False
        break
  if not f:
    break

Submission status: Time Limit Exceeded

Solution code:
#Pythonだと少し間に合わない
N = int(input())

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

Submission status: Time Limit Exceeded

Solution code:
#Pythonだと少し間に合わない
N = int(input())

x = (3500 * N + (4 * 2500 - 2 * N) - 1) //(4 * 2500 - 2 * N)
for h in range(1, x + 2):
    for n in range(3500, 0, -1):
        if (N * h * n) >= (4 * h * n - N * (h + n)) > 0:
            if (N * h * n) % (4 * h * n - N * (h + n)) == 0:
                w = (N * h * n) // (4 * h * n - N * (h + n))
                print (h, n, w)
                exit()

Submission status: Time Limit Exceeded

Solution code:
#Pythonだと少し間に合わない
N = int(input())

x = (3500 * N + (4 * 2500 - 2 * N) - 1) //(4 * 2500 - 2 * N)
for h in range(1, x + 2):
    for n in range(1, 3501):
        if (N * h * n) >= (4 * h * n - N * (h + n)) > 0:
            if (N * h * n) % (4 * h * n - N * (h + n)) == 0:
                w = (N * h * n) // (4 * h * n - N * (h + n))
                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):
        if (N * h * n) >= (4 * h * n - N * (h + n)) > 0:
            if (N * h * n) % (4 * h * n - N * (h + n)) == 0:
                w = (N * h * n) // (4 * h * n - N * (h + n))
                print (h, n, w)
                exit()

Submission status: Time Limit Exceeded

Solution code:
from itertools import product

N = int(input())

for h, n in product(range(1, 3501), range(1, 3501)):
    if ((4 * h * n) - (N * n) - (N * h)) > 0:
        if (N * h * n) % ((4 * h * n) - (N * n) - (N * h)) == 0:
            print(h, n, (N * h * n) // ((4 * h * n) - (N * n) - (N * h)))
            break

Submission status: Time Limit Exceeded

Solution code:
from itertools import product

N = int(input())

for h, n in product(range(1, 3501), range(1, 3501)):
    a = ((4 * h * n) - (N * n) - (N * h))
    if a > 0:
        if (N * h * n) % a == 0:
            w = (N * h * n) // a
            ans = [w, h, n]
            print(*ans)
            break

Submission status: Time Limit Exceeded

Solution code:
from itertools import product

N = int(input())

for h, n in product(range(1, 3501), range(1, 3501)):
    if ((4 * h * n) - (N * n) - (N * h)) > 0:
        if (N * h * n) % ((4 * h * n) - (N * n) - (N * h)) == 0:
            w = (N * h * n) // ((4 * h * n) - (N * n) - (N * h))
            ans = [w, h, n]
            print(*ans)
            break

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
for n in range(1,3501):
    for w in range(1,3501):
        if 4*n*w-N*(n+w) != 0:
            h = (N*n*w)/(4*n*w-N*(n+w))

            if h > 0 and h.is_integer():
                print(int(h), n, w)
                exit()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
for h in range(1,3501):
    for n in range(1,3501):
        try:
            tmp = n*h*N / ( 4*h*n - N*n - N* h)
        except:
            continue
        if tmp == tmp//1 and tmp > 0:
            print(h,n,int(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*h*n-N*n-N*h
		if tmp==0:continue
		w=N*n*h/tmp
		if 1<=w<=3500 and w==int(w):
			print(h,n,int(w))
			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:
			if (N * h * n) % 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):
		if (4 * n * h - N * n - N * h) != 0:
			if (N * h * n) % (4 * n * h - N * n - N * h) == 0:
				if (N * h * n) // (4 * n * h - N * n - N * h) > 0:
					print(h, n, (N * h * n) // (4 * n * h - N * n - N * h))
					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 * n * h - N * n - N * h) != 0:
			if (N * h * n) % (4 * n * h - N * n - N * h) == 0 and (N * h * n) // (4 * n * h - N * n - N * h) in range(1, 3501):
				print(h, n, (N * h * n) // (4 * n * h - N * n - N * h))
				exit()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from itertools import product

N = int(input())
for h, n in product(range(1, 3501), repeat=2):
    numer = N * h * n
    denom = 4 * h* n - N * n - N * h
    if denom == 0:
        continue
    w, r = divmod(numer, denom)
    if r == 0 and w > 0:
        print(h, n, w)
        break

Submission status: Time Limit Exceeded

Solution code:
import itertools

N = int(input())

for h, n in itertools.product(range(1, 3501), range(1, 3501)):
    if (4*n*h-N*(n+h)) == 0:
        continue
    elif N*h*n % (4*n*h-N*(n+h)) == 0 and N*h*n // (4*n*h-N*(n+h)) > 0:
        break

print(h, n, N*h*n // (4*n*h-N*(n+h)))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
for i in range(1,3501):
    h = i
    for j in range(1,3501):
        n = j
        wb = (4*h*n-N*n-N*h)
        if wb > 0:
            w = (N*h*n)/wb
            if w.is_integer() is True:
                print(h,n,int(w))
                exit()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
for i in range(1,3501):
    h = i
    for j in range(1,3501):
        n = j
        if (4*h*n-N*n-N*h) != 0:
            w = (N*h*n)/(4*h*n-N*n-N*h)
            if w.is_integer() is True and w > 1:
                print(h,n,int(w))
                exit()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

Submission status: Time Limit Exceeded

Solution code:
def calc(h,n,N):
  if 4*h*n-N*(h+n)!=0:
    return (N*h*n)//(4*h*n-N*(h+n))
  else:
    return 0

N=int(input())
for h in range(1,3501):
  for n in range(1,3501):
    w=calc(h,n,N)
    if w>0:
      if 4/N==1/h+1/n+1/w:
        print(h,n,w)
        exit()

Submission status: Time Limit Exceeded

Solution code:
from itertools import product
N = int(input())

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

Submission status: Time Limit Exceeded

Solution code:
from itertools import product
N = int(input())

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

Submission status: Time Limit Exceeded

Solution code:
def main() :
    N = int(input())
    # N = float(input())

    # 式変形していいかんじに下ごしらえして、
    # 2変数分のループで全探索する。O(3500^2)なら間に合うはず。

    # for h in range(1,3501) :
    for h in range(3500,0,-1) :
        for n in range(1,3501) :
            bo = 4*h*n - N*n - N*h
            if (bo == 0) :
                continue

            omega = (N * h * n) / bo * 1.0
            if (omega > 0 and omega.is_integer() == True) :
                print(h,n,int(omega))
                return

main()

Submission status: Time Limit Exceeded

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

    # 式変形していいかんじに下ごしらえして、
    # 2変数分のループで全探索する。O(3500^2)なら間に合うはず。

    for h in range(1,3501) :
        for n in range(1,3501) :
            bo = 4*h*n - N*n - N*h
            if (bo == 0) :
                continue

            omega = (N * h * n * 1.0) / (bo * 1.0)
            if (omega.is_integer() == True and omega > 0) :
                print(h,n,int(omega))
                return

main()

Submission status: Time Limit Exceeded

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

    # 式変形していいかんじに下ごしらえして、
    # 2変数分のループで全探索する。O(3500^2)なら間に合うはず。

    for h in range(1,3501) :
        for n in range(1,3501) :
            if ((4*h*n - N*n - N*h) == 0) :
                continue

            omega = (N * h * n * 1.0) / ((4*h*n - N*n - N*h) * 1.0)
            if (omega.is_integer() == True and omega >= 0) :
                print(h,n,int(omega))
                return

main()

Submission status: Time Limit Exceeded

Solution code:
I=int(input())

for h in range(1,3501):
    for n in range(1,3501):
        t = 4*h*n - I*h - I*n
        if t <= 0:
            continue;
        s = I*h*n
        if s % t == 0:
            print(h, n, int(s/t))
            quit()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

Submission status: Time Limit Exceeded

Solution code:
from sys import exit, stdin
N = int(stdin.readline().rstrip())
for i in range(1, 3501):
    for j in range(1, 3501):
            div = 4*i*j-N*i-N*j
            if div <= 0:
                continue
            if (N*i*j) % div == 0:
                print(i, j, (N*i*j) // div)
                exit()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:

def main():
    buf = input()
    N = int(buf)
    if N % 2 == 0:
        print(N // 2, N, N)
        return
    else:
        divisor = N
        mult = 1
        while True:
            prime_factor = prime_factorization(divisor)
            for h in prime_factor:
                for n in prime_factor:
                    for w in prime_factor:
                        if h + n + w == 4 * mult:
                            print(divisor // h, divisor // n, divisor // w)
                            return
            divisor += N
            mult += 1

def prime_factorization(number):
    n = number
    i = 2
    factor = {1: 1}
    while i * i <= n:
        while n % i == 0:
            if i in factor:
                factor[i] += 1
            else:
                factor.update({i : 1})
            n //= i
        i += 1
    if n > 1 or not factor:
        if n in factor:
            factor[n] += 1
        else:
            factor.update({n : 1})
    return factor

if __name__ == '__main__':
    main()

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+j) != 0:
            w = (n*i*j)/(4*i*j-n*(i+j))
            if w > 0 and int(w)==w:
                print(i,end=' ')
                print(j,end=' ')
                print(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):
        if 4 * i * j - n * j - n * i <= 0:
            continue
        if (n * i * j) % (4 * i * j - n * j - n * i) == 0:
            print(i, j, (n * i * j) // (4 * i * j - n * j - n * i))
            break

Submission status: Time Limit Exceeded

Solution code:
from fractions import Fraction as f
n=input()
a=f(4,n)
for i in range(1,3501):
	for j in range(1,3501):
		b=a-f(1,i)-f(1,j)
		if b.numerator==1:
			print i,j,b.denominator
			exit(0)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
p = max(N//4,1)
s=1
r=1
t=1
for i in range(2*p,3500):
    for j in range(2*p,3500):
        for l in range(p,3500):
            if (i*j + j*l + l*i)*N//(i*j*l) == 4 and (i*j + j*l + l*i)*N%(i*j*l) == 0:
                i =str(i)
                j=str(j)
                l=str(l)
                print(i+" "+j+" "+l)
                s=int(l)
                r=int(j)
                t =int(i)
                break
        if (t*r + r*s + s*t)*N//(t*r*s) == 4:
            break
    if (t*r + r*s + s*t)*N//(t*r*s) == 4:
        break

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
k = False;
for i in range(1,3501):
  if k:
    break
  for j in range(1,3501):
    if k:
      break
    if 4*i*j-n*j-n*i!=0:
      if int(n*i*j/(4*i*j-n*j-n*i))>0 and n*i*j%(4*i*j-n*j-n*i)==0 :
        print (str(i)+" "+str(j)+" "+str(int(n*i*j/(4*i*j-n*j-n*i))))
        k = True

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
k = False;
for i in range(1,3501):
  for j in range(1,3501):
    if k:
      continue
    if 4*i*j-n*j-n*i!=0:
      if int(n*i*j/(4*i*j-n*j-n*i))>0 and n*i*j%(4*i*j-n*j-n*i)==0 :
        print (str(i)+" "+str(j)+" "+str(int(n*i*j/(4*i*j-n*j-n*i))))
        k = True

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*h-N*n
    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):

        if (4*h*n - N*n - N*h) ==0:
            continue

        w = N*h*n/(4*h*n - N*n - N*h)
        flag = w.is_integer()
        # print(flag)
        
        if flag and w>0:
            print(h, n, int(w))
            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*h-N*n
    if tmp>0 and 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):
    x = 4*h*n - N*n - N*h
    y = N*h*n
    if x<=0 or y%x:
      continue
    else:
      print('{} {} {}'.format(h,n,y//x))
      exit()

Submission status: Time Limit Exceeded

Solution code:
import sys

n = int(input())

for i in range(1, 3500):
  for j in range(1, 3500):
    try:
        x = int(1 / (4/n - 1/i - 1/j))
        if x >= 1 and 4/n == 1/i + 1/j + 1/x:
            print(i, j, x)
            sys.exit()
    except:
        pass

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
s=int(input());
for n in range(3501):
 for h in range(3501):
  x=4*h*n-s*n-s*h
  if x>0:
   if ((s*h*n)/x).is_integer():
    print(int((s*h*n)/x),h,n)
    exit()

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
m=3500
for I in range(1,m**2):
    n=I//m
    h=I%m
    A=N*h*n
    B=4*h*n-N*n-N*h
    if B<=0:
        continue
    if A%B==0:
        print(h,n,A//B)
        exit()

Submission status: Time Limit Exceeded

Solution code:
s=int(input());
for n in range(1,3501):
    for h in range(1,3501):
        x=4*h*n-s*n-s*h
        if x>0:
            if ((s*h*n)/x).is_integer():
                print(int((s*h*n)/x),h,n)
                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*h*n -N*h -N*n <= 0: continue
        w = N*h*n/(4*h*n -N*h -N*n)
        if not 0<w<=3500: continue 
        if w.is_integer()==True:
            print(h,n,int(w))
            sys.exit()

Submission status: Time Limit Exceeded

Solution code:
s=int(input())
for i in range(1,3501):
    for j in range(1,3501):
        t=4*i*j-i*s-j*s
        if t<=0:
            continue
        if s*i*j%t==0:
            print(s*i*j//t,i,j)
            exit()

Submission status: Time Limit Exceeded

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

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 * j - N * i) != 0:
            w = (N * i * j) // (4 * i * j - N * j - N * i)
            if w > 0 and 4 / N == 1/ i + 1/j + 1 /w:
                print(i, j, w)
                exit()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

explore = 1
for h in range(1,3500) :
    if not explore : break
    for n in range(1,3500) :
        if (4*h*n - N*n - N*h) == 0 :
            continue
        elif (N*h*n % (4*h*n - N*n - N*h) == 0) and (N*h*n//(4*h*n - N*n - N*h) > 0) :
            w = N*h*n//((4*h*n - N*n - N*h))
            ans = [h,n,w]
            explore = 0
            break

print(*ans)

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:
            pass
        elif (N*h*n)/(4*h*n-N*n-N*h)==int((N*h*n)/(4*h*n-N*n-N*h)):
            if int((N*h*n)/(4*h*n-N*n-N*h))>0:
                print(h,n,int((N*h*n)/(4*h*n-N*n-N*h)))
                exit()

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
flag = False
for i in range(3500):
    for j in range(i, 3500):
        num = n * i * j
        den = 4 * i * j - i * n - j * n
        if den > 0 and not num % den:
            k = num // den
            print("{} {} {}".format(i, j, k))
            flag = True
            break
    if flag:
        break

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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:
            continue
        elif (N*i*j)%4*i*j-N*i-N*j==0:
            print(i,j,(N*i*j)//4*i*j-N*i-N*j)
            exit()

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
for i in range(1,3501):
    for j in range(1,3501):
        bw=4*i*j-N*i-N*j
        if bw<=0:
            continue
        elif (N*i*j)%bw==0:
            print(i,j,(N*i*j)//bw)
            exit()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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)<=3500*(4*h*n-N*n-N*h) and (N*h*n)%(4*h*n-N*n-N*h)==0:
            w = (N*h*n) // (4*h*n-N*n-N*h)
            print(h,n,w)
            exit()