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())

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

Submission status: Wrong Answer

Solution code:
N = int(input())

for w in range(1, 3501):
    for h in range(1, 3501):
        n = 4/N - 1/w - 1/h
        if n <= 0:
            continue
        if abs(1/n - int(1/n)) < 1e-8:
            print(h, w, int(1/n))
            exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
h, n, w = N, N, N/2
print(h, n, w)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())

if n%2==0:
    print(int(n/2),n,n)
else:
    print('no')

Submission status: Wrong Answer

Solution code:
import math
N=int(input())
h_max=math.floor(3*N/4)
d=10**(-5)
for h in range(1,min(h_max+1,3501)):
     if 4/N - 1/h == 0:
          continue
     n_max=math.floor(2/(4/N - 1/h))
     for n in range(h,min(n_max+1,3501)):
          if 4/N-1/h-1/n == 0:
               continue
          w=1/(4/N-1/h-1/n)
          if int(w)-d<w and w<int(w)+d and int(w)>=n:
               print(h,n,int(w))
               break
     else:
          continue
     break

Submission status: Wrong Answer

Solution code:
import math
N=int(input())
h_max=math.floor(3*N/4)
for h in range(1,min(h_max+1,3501)):
     if 4/N - 1/h == 0:
          continue
     n_max=math.floor(2/(4/N - 1/h))
     for n in range(h,min(n_max+1,3501)):
          if 4/N-1/h-1/n == 0:
               continue
          w=1/(4/N-1/h-1/n)
          if w==int(w) and w>=n:
               print(h,n,int(w))
               break
     else:
          continue
     break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

N = int(input())

if N%4 == 0:    N += 0.1  
for h in range(math.ceil(N/4),3501):
    for n in range(math.ceil(1/(4/N-1/h)),3501):
        a = 4/N - 1/h - 1/n
        if a!= 0:
            w = 1/a
            if 4*h*n*int(w) == N*(h*n+n*int(w)+int(w)*h):
                break
    else:
        continue
    break

print(h,n,int(w))

Submission status: Wrong Answer

Solution code:
import math

N = int(input())

for h in range(3501):
    if 4*h > N:
        for n in range(math.ceil(1/(4/N-1/h)),3501):
            a = 4/N - 1/h - 1/n
            if a!= 0:
                w = 1/a
                if w == int(w):
                    break
        else:
            continue
        break

print(h,n,int(w))

Submission status: Wrong Answer

Solution code:
N = int(input())

num = 3505

for i in range(1, num):
    if 4 / N > 1 / i:
        for j in range(1, num):
            if 4 / N > 1 / i + 1 / j:
                w = 1 / (4 / N - 1 / j - 1 / i)
                if w.is_integer():
                    print(i, j, int(w))
                    exit()

Submission status: Wrong Answer

Solution code:
N = int(input())

num = 3501

for i in range(1, num):
    if 4 / N > 1 / i:
        for j in range(1, num):
            if 4 / N > 1 / i + 1 / j:
                w = 1 / (4 / N - 1 / j - 1 / i)
                if w.is_integer():
                    print(i, j, int(w))
                    exit()

Submission status: Wrong Answer

Solution code:
N = int(input())

num = 3501

for i in range(1, num):
    if 4 / N > 1 / i:
        for j in range(1, num):
            if 4 / N > 1 / i + 1 / j:
                w = 1 / (4 / N - 1 / j - 1 / i)
                if w.is_integer():
                    print(i, j, int(w))
                    print(4 / N, 1 / i + 1 / j + 1 / int(w))
                    exit()

Submission status: Wrong Answer

Solution code:
N = int(input())

num = 3501

for i in range(1, num):
    if 4 / N > 1 / i:
        for j in range(1, num):
            if 4 / N != 1 / i + 1 / j:
                w = 1 / (4 / N - 1 / j - 1 / i)
                if int(w) == w and w >= 1:
                    print(i, j, int(w))
                    exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
if N % 2:
    k = (N+1)//2
    print(k,k,k*N//2)
else:
    print(N,N,N//2)

Submission status: Wrong Answer

Solution code:
from math import floor
import sys
ns = int(input())
for h in range(1, 3501):
    for n in range(h, 3501):
        if(4 - ns / h - ns / n == 0): continue
        w = float(ns / (4 - ns / h - ns / n) )
        if(w.is_integer() and w > 0):
            print("{} {} {}".format(h, n, int(w)))
            exit()

Submission status: Wrong Answer

Solution code:
N=int(input())

for a in range(1,3501):
    for b in range(a,3501):
        if 4*a*b-N*b-N*a==0:
            pass
        else:
            c=N*a*b/(4*a*b-N*b-N*a)
            if (4*a*b)%(N*(a*b+(a+b)*c))==0:
                if 4*a*b==(a*b+b*int(c)+int(c)*a)*N:
                    print(a,b,int(c))
                    exit()

Submission status: Wrong Answer

Solution code:
N=int(input())

for a in range(1,3501):
    for b in range(a,3501):
        if a*b-N*(a+b)==0:
            pass
        else:
            c=N*a*b/(a*b-N*(a+b))
            if (a*b*c)%(N*(a*b+b*c+c*a))==0 and c==int(c) and c>0:
                print(a,b,int(c))
                exit()

Submission status: Wrong Answer

Solution code:
N=int(input())
flag=0
for a in range(1,3501):
    if flag==1:
        break
    for b in range(1,3501):
        if 4*a*b!=N*(a+b):
            if (N*a*b)%(4*a*b-N*(a+b))==0 and (N*a*b)//(4*a*b-N*(a+b))>0 :
                flag=1
                c=(N*a*b)//(4*a*b-N*(a+b))
                break
    
print(a,b,c)

Submission status: Wrong Answer

Solution code:
N=int(input())
h,n,w=0,0,0
start=N/4
if start.is_integer()==True:
  h=int(start*3)
  n=int(start*3)
  w=int(start*3)
else:
  h=int(N/4)+1
  second=N*h/(4*h-N)
  if second.is_integer()==True:
    n=int(second*2)
    w=int(second*2)
  else:
    n=int(N*h/(4*h-N))+1
    w=int(N*h*n/(4*h*n-N*n-N*h))
print("{0} {1} {2}".format(h,n,w))

Submission status: Wrong Answer

Solution code:
N=int(input())

if N==2:
  print('1 2 2')
  
if N==3:
  print('1 6 6')

if N==4:
  print('2 4 4')

for h in range(N//4 +1, min(3501, 3*N//4 +1)):
  for n in range((N*h)//(4*h-N), min(3501, (2*N*h)//(4*h-N))):
    x = 4*h*n - N*n - N*h
    y = N*h*n
    if x>0 and not y%x:
      print('{} {} {}'.format(h,n,y//x))
      exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
flag=True
for a in range(3500):
    for b in range(3500):
        if 4*a*b-n*(a+b)!=0 and n*a*b//(4*a*b-n*(a+b))>0:
            print(a,b,n*a*b//(4*a*b-n*(a+b)))
            flag=False
            break
    if flag==False:
        break

Submission status: Wrong Answer

Solution code:
N=int(input())

for h in range(N//4 +1, min(3501, 3*N//4 +1)):
  for n in range((N*h)//(4*h-N), min(3501, (2*N*h)//(4*h-N))):
    x = 4*h*n - N*n - N*h
    y = N*h*n
    if x>0 and not y%x:
      print('{} {} {}'.format(h,n,y//x))
      exit()

Submission status: Wrong Answer

Solution code:
N=int(input())
h,n,w=0,0,0
h=int(N/4)+1
n=int(N*h/(4*h-N))+1
w=int(N*h*n/(4*h*n-N*n-N*h))
print("{0} {1} {2}".format(h,n,w))

Submission status: Wrong Answer

Solution code:
N = int(input())
flag = True
for h in range(1,3501):
    for n in range(1,3501):
        if 4*h*n-N*(n+h) == 0:
            continue
        if flag and (N*n*h) % (4*h*n-N*(n+h)) == 0:
            print(str(h)+' '+str(N*n*h //(4*h*n-N*(n+h)))+' '+str(n))
            flag = False
        if not flag:
            break
    if not flag:
        break

Submission status: Wrong Answer

Solution code:
n=int(input())
if n%2==0:
    print(n//2,n,n)
elif n%4==1:
    a=n//4+1
    b=(n*a)//3+1
    print(a,b,n*a*b//(4*a*b-n*(a+b)))
else:
    print(n//4+1,n*(n//4+1)*2,n*(n//4+1)*2)

Submission status: Wrong Answer

Solution code:
from fractions import Fraction
n=int(input())
ans=4/n
for h in range(1,3501):
  for n in range(1,3501):
      if str(Fraction(ans-1/h-1/n))[0]=="1":
        index=(str(Fraction(ans-1/h-1/n)).index("/"))
        print(h,n,str(Fraction(ans-1/h-1/n))[index+1:])
        exit()

Submission status: Wrong Answer

Solution code:
import sys

n = int(input())

def main():
    for i in range(1, 3500):
        for j in range(1, 3500):
            y = 4/n - 1/i - 1/j
            if y > 0:
                x = int(1 / y)
                if x >= 1 and y == 1/x:
                    print(i, j, x)
                    sys.exit()


main()

Submission status: Wrong Answer

Solution code:
n=int(input())
if n%2==0:
    print(n//2,n,n)
else:
    a=n//4+1
    b=(n*(n//4+1))//3+1
    print(a,b,n*a*b//(4*a*b-n*(a+b)))

Submission status: Wrong Answer

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 1 <= x <= 3500 and 4/n == 1/i + 1/j + 1/x:
            print(i, j, x)
            sys.exit()
    except:
        pass

Submission status: Wrong Answer

Solution code:
N=int(input())

for a in range(1,3501):
    for b in range(a,3501):
        if 4*a*b-N*b-N*a==0:
            pass
        else:
            c=N*a*b/(4*a*b-N*b-N*a)
            if 4*a*b==N*(a*b+(a+b)*c):
                if 4*a*b==(a*b+b*int(c)+int(c)*a)*N:
                    print(a,b,int(c))
                    exit()

Submission status: Wrong Answer

Solution code:
N=int(input())

for a in range(1,3501):
    for b in range(a,3501):
        if 4*a*b-N*b-N*a==0:
            pass
        else:
            c=N*a*b/(4*a*b-N*b-N*a)
            if 4*a*b==N*(a*b+(a+b)*c):
                if 1/N==(1/a)+(1/b)+(1/int(c)):
                    print(a,b,int(c))
                    exit()

Submission status: Wrong Answer

Solution code:
N=int(input())

for a in range(1,3501):
    for b in range(a,3501):
        if 4*a*b-N*b-N*a==0:
            pass
        else:
            c=N*a*b/(4*a*b-N*b-N*a)
            if 4*a*b==N*(a*b+(a+b)*c):
                print(a,b,int(c))
                exit()

Submission status: Wrong Answer

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 w.is_integer()==True:
            print(h,n,int(w))
            sys.exit()

Submission status: Wrong Answer

Solution code:
s=int(input())
c=0
for i in range(1,3501):
    if c==1:
        break
    else:
        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)
                    c=1

Submission status: Wrong Answer

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:
                print(i, j, w)
                exit()

Submission status: Wrong Answer

Solution code:
int(input())
print(2,1,2)

Submission status: Wrong Answer

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 and aw/bw==int(aw/bw):
            h=i
            n=j
            break
print(h,n,int(bw/aw))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
for a in range(1,3501):
    for b in range(1,3501):
        c = 4/n - 1/a - 1/b
        if c > 0:
            c = 1 / c
            if abs(c-int(c)) <= 10**(-11):
                print(a,b,int(c))
                exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
for a in range(1,3501):
    for b in range(1,3501):
        c = 4/n - 1/a - 1/b
        if c > 0:
            c = 1 / c
            if abs(c-int(c)) <= 10**(-8):
                print(a,b,int(c))
                exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
for a in range(1,3501):
    for b in range(1,3501):
        c = 4/n - 1/a - 1/b
        if c > 0:
            c = 1 / c
            if abs(c-int(c)) <= 10**(-5):
                print(a,b,int(c))
                exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
if N > 0:
    if not N in [3, 9, 27, 81, 243, 729, 2187]:
        for i in range(2, 3501, 3):
            for n in range(1, 1751):
                w = i * n
                if 3 * w == N * (i + 1):
                    print("{} {} {}".format(N, n, w))
                    exit()
    else:
        print("{} {} {}".format(N // 3, N * 2, N * 2))

Submission status: Wrong Answer

Solution code:
N = int(input())
if N > 0:
    for i in range(2, 3501, 3):
        for n in range(1, 1751):
            w = i * n
            if 3 * w == N * (i + 1):
                print("{} {} {}".format(N, n, w))
                exit()
else:
    for i in range(4, 3500, 5):
        for n in range(1, 876):
            w = i * n
            if -5 * w == N * (i + 1):
                print("{} {} {}".format(N, n, w))
                exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
if N > 0:
    for i in range(2, 3501, 3):
        for n in range(1, 1751):
            w = i * n
            if 3 * w == N * (i + 1):
                print("{} {} {}".format(N, n, w))
                exit()

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin

def li(): return [int(x) for x in stdin.readline().split()]
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return [float(x) for x in stdin.readline().split()]
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(ns())
def nf(): return float(ns())



N = ni()
MAX = 3500
EPS = 10**(-6)
ha,wa,na = 0,0,0

for h in range(MAX+1):
    for w in range(MAX+1):
        if 4*h*w - N*w - N*h > 0:            
            if abs(((N*h*w) / (4*h*w - N*w - N*h)) - ((N*h*w) // (4*h*w - N*w - N*h))) < EPS:
                ha = h
                wa = w
                na = (N*h*w) // (4*h*w - N*w - N*h)
                
print(ha,na,wa)

Submission status: Wrong Answer

Solution code:
N = int(input())
h_limit = N * 3 // 4
ok = False

for h in range(1, 3501):
	for n in range(1, 3501):
			if 1 / h + 1 / n < 4 / N:
				w = 1 / (4 / N - 1 / h - 1 / n)
				if w > 0 and abs(w - int(w)) < 10 ** (-7):
					print(h, n, int(w))
					ok = True
					break

	if ok:
		break

Submission status: Wrong Answer

Solution code:
N = int(input())
h_limit = N * 3 // 4
ok = False

for h in range(1, h_limit + 1):
	#(4 / N - 1 / h) / 2 <= 1 / N
	if 4 * h == N:
		continue
	n_limit = 2 * N * h // (4 * h - N)
	for n in range(h, n_limit + 1):
		if 1 / h + 1 / n == 4 / N:
			continue
		w = 1 / (4 / N - 1 / h - 1 / n)
		if w > 0 and abs(w - int(w)) < 10 ** (-7):
			print(h, n, int(w))
			ok = True
			break

	if ok:
		break

Submission status: Wrong Answer

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 = float((n*i*j)/(4*i*j-n*j-n*i))
			if w > 0 and w.is_integer() :
				print i,j,int(w)
				quit()

Submission status: Wrong Answer

Solution code:
n = int(input())

for i in range(1,3501):
	for j in range(1,3501):
		w = float((n*i*j)/4*i*j-n*j-n*i)
		if w > 0 and w.is_integer() :
			print i,j,int(w)
			quit()

Submission status: Wrong Answer

Solution code:
N=int(input())
 
for h in range(1,3500):
  for n in range(1,3500):
    #divが負数ならwは負数になる
    if (4*h*n)-(N*n)-(N*h)>0:
      w=N*h*n/(4*h*n)-(N*n)-(N*h)
      if w.is_integer():
        print(h,n,int(w))
        exit()

Submission status: Wrong Answer

Solution code:
N=int(input())

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
if N % 2 == 0:
    print(N // 2, N, N)
    quit()
for h in range(1, 3500+1):
    hN = h * N
    for n in range(h, 3500+1):
        b = (4 * h * n - n * N - hN)
        if b > 0:
            continue
        a = (n * hN)
        if a % b == 0:
            print(h, n, a // b)
            quit()

Submission status: Wrong Answer

Solution code:
N = int(input())
for h in range(1, 3500+1):
    for n in range(h, 3500+1):
        t = (4 - N/h - N/n)
        if t > 0 and N/t % 1 == 0:
            print(h, n, int(N/t))
            quit()

Submission status: Wrong Answer

Solution code:
from sys import stdin

gets = stdin.readline


def main():
    n = int(gets())
    h, w = 0, 0
    flag = False
    for _ in range(3500):
        h += 1
        w = 0
        for _ in range(3500):
            w += 1
            y = (4 * h * w - n * (h + w))
            if y > 0:
                modulo = n % y + h % y + w % y
                if modulo % y == 0:
                    print(h, w, (n*h*w)//y)
                    flag = True
                    break
        if flag:
            break
    return


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from fractions import *
q=int(input())
n=Fraction(4,q)
ok=0
for i in range(1,3501):
	p=n-Fraction(1,i)-Fraction(1,q)
	if ok:break
	if(p.numerator==1):
		print(i,q,p.denominator)
		ok=1

Submission status: Wrong Answer

Solution code:
import sys
N=int(input())
if N%2==0:
  print(N//2,N,N)
else:
  for a in range(1,3501):
    for b in range(1,a):
      M=N*a*b
      L=4*a*b-N*(a+b)
      if M%L==0:
        print(a,b,M)
        sys.exit()

Submission status: Wrong Answer

Solution code:
N=int(input())

import sys

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

        w=a/b
        #w=int(w)

        if w<h:
            break

        #print(n,w)
        if a%b==0:
            if N*(n*w+h*w+h*n)!=4*n*w*h:
                continue
            #print(w)
            if w>0:
                w=int(w)
                print(h,n,w)
                '''

                print(4/N)
                print(1/h+1/n+1/w)
                print(a,b)
                print(a/b)
                '''
                sys.exit()

Submission status: Wrong Answer

Solution code:
import math

originN = int(raw_input())
N = originN
primes = []
while True:
    if N % 2 == 0:
        primes.append(2)
        N /= 2
    else:
        break
i = 3
while True:
    if N == 1 or N < i**2:
        break
    while True:
        if N % i == 0:
            primes.append(i)
            N /= i
        else:
            break
    i += 2
if N != 1:
    primes.append(N)
if primes[0] == 2:
    print str(N/2)+" "+str(N*2)+" "+str(N*2)
elif primes[0] == 3:
    print str(N/3)+" "+str(N*2)+" "+str(N*2)
else:
    p = int(math.ceil(float(primes[0])/4.0))
    if primes[0] % 4 == 1:
        if p % 2 == 0:
            print str(N/primes[0]*p)+" "+str(N*p/2)+" "+str(N*p)
        else:
            isValid = False
            for h in xrange(1, 3501):
                for n in xrange(1, 3501):
                    if (4*n*h-n*N-h*N) > 0 and (N*n*h) % (4*n*h-n*N-h*N) == 0:
                        isValid = True
                        print str(h)+" "+str(n)+" "+str((N*n*h)/(4*n*h-n*N-h*N))
                        break
                if isValid: break
    else:
        print str(N/primes[0]*p)+" "+str(N*p*2)+" "+str(N*p*2)

Submission status: Wrong Answer

Solution code:
import math

originN = int(raw_input())
N = originN
primes = []
while True:
    if N % 2 == 0:
        primes.append(2)
        N /= 2
    else:
        break
i = 3
while True:
    if N == 1 or N < i**2:
        break
    while True:
        if N % i == 0:
            primes.append(i)
            N /= i
        else:
            break
    i += 2
if N != 1:
    primes.append(N)
print primes
if primes[0] == 2:
    print str(N/2)+" "+str(N*2)+" "+str(N*2)
elif primes[0] == 3:
    print str(N/3)+" "+str(N*2)+" "+str(N*2)
else:
    p = int(math.ceil(float(primes[0])/4.0))
    if primes[0] % 4 == 1:
        if p % 2 == 0:
            print str(N/primes[0]*p)+" "+str(N*p/2)+" "+str(N*p)
        else:
            isValid = False
            for h in xrange(1, 3501):
                for n in xrange(1, 3501):
                    if (4*n*h-n*N-h*N) > 0 and (N*n*h) % (4*n*h-n*N-h*N) == 0:
                        isValid = True
                        print str(h)+" "+str(n)+" "+str((N*n*h)/(4*n*h-n*N-h*N))
                        break
                if isValid: break
    else:
        print str(N/primes[0]*p)+" "+str(N*p*2)+" "+str(N*p*2)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
from itertools import combinations


def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n /= i
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table


def find_result(primes, cond, total):
    combi = {}
    for i in range(len(primes)):
        for c in combinations(primes, i+1):
            s = reduce(lambda x, y: x * y, c)
            if s <= cond - 2 and total / s < 3500:
                combi[tuple(c)] = s

    keys = sorted(combi.keys())
    for h in keys:
        for n in keys:
            for w in keys:
                s = combi[h] + combi[n] + combi[w]
                if s == cond:
                    return combi[h], combi[n], combi[w]
    return None


N = int(raw_input())
primes = [
    1,
] + prime_decomposition(N)

for i in range(2, 4):
    cond = i * 4
    all_primes = primes + prime_decomposition(i)
    total = reduce(lambda x, y: x * y, all_primes)
    candi_primes = [p for p in all_primes if p <= cond - 2]

    r = find_result(candi_primes, cond, total)
    if r is not None:
        h, n, w = r
        print '{} {} {}'.format(int(total/h), int(total/n), int(total/w))
        break

Submission status: Wrong Answer

Solution code:
# coding: utf-8
from itertools import combinations


def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n /= i
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table


def find_result(primes, cond):
    combi = {}
    for i in range(len(primes)):
        for c in combinations(primes, i+1):
            s = reduce(lambda x, y: x * y, c)
            if s <= cond - 2:
                combi[tuple(c)] = s

    keys = sorted(combi.keys())
    for h in keys:
        for n in keys:
            for w in keys:
                s = combi[h] + combi[n] + combi[w]
                if s == cond:
                    return combi[h], combi[n], combi[w]
    return None


N = int(raw_input())
primes = [
    1,
] + prime_decomposition(N)

for i in range(2, 4):
    cond = i * 4
    all_primes = primes + prime_decomposition(i)
    total = reduce(lambda x, y: x * y, all_primes)
    candi_primes = [p for p in all_primes if p <= cond - 2]

    r = find_result(candi_primes, cond)
    if r is not None:
        h, n, w = r
        print '{} {} {}'.format(int(total/h), int(total/n), int(total/w))
        break

Submission status: Wrong Answer

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

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import re
import string

N = int(input())


def get_a(N):
    a = 1
    while True:
        if N < 4 * a:
            return a, 4*a-N, N*a
        a += 1

def get_b(N1, N2):
    b = 1
    while True:
        if N2 < b * N1:
            return b, b*N1-N2, b*N2
        b += 1

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def solve(N):
    if N == 2:
        print(1, 2, 2)
    elif N % 2 == 0:
        print(N, N, N // 2)
    elif N % 4 == 1:
        n = (N - 1) // 4
        h = N * n
        print(h, n*2, n*2)
    elif N % 12 == 3:
        m = (N - 3) // 12
        h = m * N
        print(h, m*6, m*6)
    else:
        a, N1, N2 = get_a(N)
        # print("a,N1,N2 = ", a, N1, N2)
        b, N1, N2 = get_b(N1, N2)
        # print("b,N1,N2 = ", b, N1, N2)
        g = gcd(N1,N2)
        N1 //= g
        N2 //= g
        # assert(N1 == 1)
        print(a, b, N2)

# for N in range(2, 100):
#     # print("N:::", N)
#     solve(N)
    
solve(N)

Submission status: Wrong Answer

Solution code:
N=int(input())

import sys

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

        w=a/b
        w=int(w)

        if w<h:
            break

        #print(n,w)
        if a%b==0:
            if N*(n*w+h*w+h*n)!=4*n*w*h:
                continue
            #print(w)
            if w>0:
                print(h,n,w)
                '''

                print(4/N)
                print(1/h+1/n+1/w)
                print(a,b)
                print(a/b)
                '''
                sys.exit()

Submission status: Wrong Answer

Solution code:
N=int(input())

import sys

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

        w=a/b
        w=int(w)

        if w<h:
            break

        #print(n,w)
        if a%b==0:

            #print(w)
            if w>0:
                if round(4/N,5)==round(1/h+1/n+1/w,5):
                    print(h,n,w)
                    sys.exit()

Submission status: Wrong Answer

Solution code:
N=int(input())

import sys

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

        w=a/b
        w=int(w)

        if w<h:
            break

        #print(n,w)
        if a%b==0:

            #print(w)
            if w>0:
                if round(N/4,5)==round(1/h+1/n+1/w,5):
                    print(h,n,w)
                    sys.exit()

Submission status: Wrong Answer

Solution code:
N=int(input())

import sys

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

        w=a/b
        w=int(w)

        if w<h:
            break

        #print(n,w)
        if a%b==0:

            #print(w)
            if w>0:
                if N/4==1/h+1/n+1/w:
                    print(h,n,w)
                    sys.exit()

Submission status: Wrong Answer

Solution code:
N=int(input())

import sys

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

        if h*n*N==0:
            continue

        w=a/b
        if w<h:
            break
        w=int(w)
        #print(n,w)
        if a%b==0:

            #print(w)
            if w>0:
                print(h,n,w)
                sys.exit()

Submission status: Wrong Answer

Solution code:
N = int(input())

def divide(m, n):
    for i in reversed(range(2, m + 1)):
        if m % i == 0 and n % i == 0:
            m = int(m / i)
            n = int(n / i)
            return (m, n)
    return (m, n)

a = 4
b = N

a, b = divide(a, b)
h = b // a + 1
a = a * h - b
b = b * h

a, b = divide(a, b)
n = b // a + 1
a = a * n - b
b = b * n

a, b = divide(a, b)
w = b
print(str(h) + ' ' + str(n) + ' ' + str(w))

Submission status: Wrong Answer

Solution code:
from fractions import Fraction
from math import ceil


N = int(input())
for h in range(ceil(N / 4), ceil(N / 4)*1000):
    r = Fraction(4, N) - Fraction(1, h)
    if r.numerator > 0:
        n = ceil(r.denominator / r.numerator)
    else:
        h, n = h+1, h * (h+1)
        r = Fraction(4, N) - Fraction(1, h)

    r -= Fraction(1, n)
    if r.numerator > 0:
        w = ceil(r.denominator / r.numerator)
        r -= Fraction(1, w)
    else:
        n, w = n+1, n*(n+1)
        r = Fraction(4, N) - Fraction(1, h) - Fraction(1, n) - Fraction(1, w)

    if r == 0:
        print(h-ceil(N / 4))
        #print(h, n, w)
        break

Submission status: Wrong Answer

Solution code:
N=int(input())

import sys

for h in range(1,3501):
    for n in range(h,3501):
        a=(h*n*N)
        b=(4*h*n-(n+h)*N)
        if b==0:
            continue
        w=a/b
        if w<h:
            break
        w=int(w)
        #print(n,w)
        if a%b==0:

            #print(w)
            if w>0:
                print(h,n,w)
                sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
N=int(input())
if N%2==0:
  print(N//2,N,N)
elif N%4==3:
  m=N//4+1
  a=m
  b=(4*m-1)*(m+1)
  c=a*b
  print(a,b,c)
elif N%4==1:
  m=N//4+1
  a=m
  b=(5*m-1)*(4*m-3)
  c=m*(5*m-1)
  print(a,b,c)

Submission status: Wrong Answer

Solution code:
N = int(input())

def divide(m, n):
    for i in range(2, m + 1):
        if m % i == 0 and n % i == 0:
            m = int(m / i)
            n = int(n / i)
    return (m, n)

a = 4
b = N

a, b = divide(a, b)
h = b // a + 1
a = a * h - b
b = b * h

a, b = divide(a, b)
n = b // a + 1
a = a * n - b
b = b * n

a, b = divide(a, b)
w = b
print(str(h) + ' ' + str(n) + ' ' + str(w))