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: Accepted

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

Submission status: Accepted

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

jdg = True

for h in range(math.ceil(N/4), 3501):
    for n in range(h, 3501):
        num = 4*h*n - N*h - N*n
        if num > 0:
            if (N * n * h) % num == 0:
                jdg = False
                break
    if not jdg: break

w = N*h*n//(num)
print(*[h, n, w])

Submission status: Accepted

Solution code:
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

N = I()

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

print(h,n,w)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
for h in range(1, 3501):
    for n in range(h, 3501):
        ok = 0
        ng = 3501
        while abs(ok-ng)>1:
            w = (ok+ng)//2
            if 4*h*n*w<=N*(n*w+w*h+h*n):
                ok = w
            else:
                ng = w
        if 4*h*n*ok==N*(n*ok+ok*h+h*n):
            print(h, n, ok)
            exit()

Submission status: Accepted

Solution code:
import sys
#import numpy as np
import math
#from fractions import Fraction
#import itertools
from collections import deque
#import heapq
from fractions  import gcd
input=sys.stdin.readline
w=0
ah=an=0
N=int(input())
for h in range(1,3501):
    for n in range(h,3501):
        if (4*h*n-N*n-N*h)!=0 and N*n*h%(4*h*n-N*n-N*h)==0:
            w=N*n*h//(4*h*n-N*n-N*h)
            ah=h
            an=n
            break
print(ah,an,w)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
#Tenka1 Programmer Contest-C 4/N
"""
nが与えられるので、
4/n = 1/a + 1/b + 1/c　となるa,b,cを出力せよ
なお、a,b,c<=3500となる中で1つは解があることが保証される。

多分半分全列挙のような解法になると思う

"""
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
n = int(readline())
flag = 0
for a in range(1,3501):
    for b in range(1,3501):
        try:
            c = int(a*b*n/(4*a*b-n*b-n*a))
            if c<0:
                continue
            if 4*a*b*c//(b*c+c*a+a*b)==n:
                print(a,b,c)
                flag = 1
        except:
            pass
        if flag:
            exit()

Submission status: Accepted

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

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

SIZE = 3501

def main():
    N = Z()
    for i in range(1, SIZE):
        for j in range(1, SIZE):
            x = N * i * j
            y = 4*i*j - N * (i+j)
            if y > 0 and x%y == 0:
                print(i, j, x//y)
                break
        else: continue
        break

    return

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
#======================================================#
def main():
    N = II()
    MAX=3500
    for h in range(1,MAX+1):
        for n in range(1,MAX+1):
            d = 4*h*n-N*h-N*n
            if d > 0 and (N*h*n)%d==0:
                print('{} {} {}'.format(h, n, (N*h*n)//d))
                return None

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N = int(readline())
    for n in range(1,3501):
        for h in range(1,3501):
            x = 4*n*h-N*n-N*h
            if x<=0:
                continue
            else:
                if (N*h*n)%x==0:
                    print(n, h, (N*h*n)//x)
                    exit()


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
import math
U = math.ceil(3*N/4)
D = math.ceil(N/4)
if N % 2 == 0:
  ans = (N,N,N//2)
else:
  if D%2 == 1:
    D += 1
  h = -1
  for n in range(D,3500):
    if h > 0:
      break
    for w in range(n,3500):
      #print(h,n,w)
      if w*n*N/(4*n*w-w*N-n*N) == int(w*n*N/(4*n*w-w*N-n*N)):
        h = w*n*N//(4*n*w-w*N-n*N)
        ans = (w*n*N//(4*n*w-w*N-n*N),n,w)
        break
        
print(*ans)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
N = int(input())

for h in range(1, 3501):
    for n in range(h, 3501):
        x = 4*h*n-N*n-N*h
        if x <= 0:
            continue
        else:
            if (N*h*n)%x == 0:
                print(h, n, (N*h*n)//x)
                exit()

Submission status: Accepted

Solution code:
import sys


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

    for i in range(1, 3501):
        for j in range(1, 3501):
            if(4*i*j-N*(i+j) > 0):
                if((N*i*j)%(4*i*j-N*(i+j)) == 0):
                    print(i, j, int((N*i*j/(4*i*j-N*(i+j)))))
                    sys.exit()
                    
main()

Submission status: Accepted

Solution code:
def main():
    N = int( input())
    for x in range(1,3501):
        if 4*x - N < 0:
            continue
        for y in range(1, 3501):
            if 4*x*y <= N*(x+y):
                continue
            if N*x*y%(4*x*y-N*(x+y)) == 0:
                print(x, y, N*x*y//(4*x*y-N*(x+y)))
                return
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    N = int( input())
    for x in range(1,3501):
        for y in range(1, 3501):
            if 4*x*y <= N*(x+y):
                continue
            if N*x*y%(4*x*y-N*(x+y)) == 0:
                print(x, y, N*x*y//(4*x*y-N*(x+y)))
                return
if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    for a in range(n//4+1,3501):
        for b in range(n*a//(4*a-n),3501):
            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)))
                sys.exit()

if __name__=='__main__':
    main()

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    for a in range(1,3501):
        for b in range(a,3501):
            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)))
                sys.exit()

if __name__=='__main__':
    main()

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    for a in range(n//4+1,3501):
        for b in range(n*a//(4*a-n),3501):
            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)))
                sys.exit()

if __name__=='__main__':
    main()

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    for a in range(1,3501):
        for b in range(a,3501):
            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)))
                sys.exit()

if __name__=='__main__':
    main()

Submission status: Accepted

Solution code:
N=int(input())

for h in range(1,3501):
    for n in range(h,3501):
        x=(4*n*h-n*N-h*N)
        if x<=0 or n*h*N%x:continue
        print(h,n,n*h*N//x )
        exit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
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.is_integer() and 1 <= w:
			print(h, n, int(w))
			exit()

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    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.is_integer() and w > 0 and 4 * h * n * w == N * n * w + N * h * w + N * h * n:
                    print(h, n, int(w))
                    exit()


if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
import math
const=3500+1
N = int(input())
ans=4/N
flg=False
for h in range(int(N/4),const):
    for n in range(h,const):
        tmp=4*h*n-N*n-N*h
        if tmp != 0:
            w = N*h*n/tmp
            if w == int(w) and w>0:
                print(h,n,int(w) )
                flg=True
                break
    if flg==True:
        break

Submission status: Accepted

Solution code:
def main(n):
  if n%2==0:
    print(n,n,n//2)
    exit()
  if n==3:
    print(2,2,3)
    exit()
  s=n//4
  for i in range(2*s,3500*2):
    for a in range(s,i-3):
      b=i-a
      c=a*b*n/(4*a*b-n*b-n*a)
      if float.is_integer(c) and c>0:
        print(a,b,int(c))
        exit()

if __name__=='__main__':
  import sys
  input = sys.stdin.readline
  n=int(input())
  main(n)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    def main():
        N=int(input())
        for h in range(1,3501):
            for n in range(h,3501):
                if 4*h*n-N*n-N*h==0:
                    continue
                else:
                    temp=(N*h*n)/(4*h*n-N*n-N*h)
                    if temp>0 and temp.is_integer():
                        return [h,n,int(temp)]
    for i in main():
        print(i,end=' ')


resolve()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    def main():
        N=int(input())
        while True:
            for h in range(1,3501):
                for n in range(h,3501):
                    if 4*h*n-N*n-N*h==0:
                        continue
                    else:
                        temp=(N*h*n)/(4*h*n-N*n-N*h)
                        if temp>0 and temp.is_integer():
                            return [h,n,int(temp)]
    for i in main():
        print(i,end=' ')


resolve()

Submission status: Accepted

Solution code:
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
for h in range(1,3501):
    for m in range(1,3501):
        x = 4*h*m-n*m-n*h
        if x>0 and n*h*m%x==0:
            w = n*h*m//x
            print("{} {} {}".format(h,m,w))
            #ddprint(f"{4/n} {1/h+1/m+1/w}")
            exit()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

if N%2 == 0:
  print(N, N, N//2)
else:
  for h in range(1, 3501):
    if 4*h <= N:
      continue
    for n in range(h, 3501):
      num = N*h*n
      dem = 4*h*n - N*(h+n)
      if dem > 0 and num%dem == 0:
        print(h, n, num//dem)
        quit()

Submission status: Accepted

Solution code:
N = int(input())

if N%2 == 0:
  print(N, N, N//2)
else:
  for h in range(3500, -1, -1):
    num = N*h*h; diff_num = N*h
    dem = 4*h*h - N*(h+h); diff_dem = 4*h - N
    for n in range(h, -1, -1):
      if dem <= 0:
        break
      if num%dem == 0:
        print(h, n, num//dem)
        quit()
      num -= diff_num
      dem -= diff_dem

Submission status: Accepted

Solution code:
N = int(input())

if N%4 == 0:
    print(*[(3*N)//4]*3)
else:
    for w in range(1, 3501):
        for n in range(w+1, 3501):
            if 4*n*w - w*N - n*N <= 0:
                continue
            elif (n*w*N) % (4*n*w - w*N - n*N) == 0:
                h = (n*w*N) // (4*n*w - w*N - n*N)
                print(h, n, w)
                exit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


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

    for h in range(1, 3501):
        for n in range(1, 3501):
            numerator = 4 * h * n - N * (h + n)
            denominator = N * h * n
            if (numerator >= 1) and (numerator <= denominator):
                if denominator % numerator == 0:
                    w = denominator // numerator
                    return print(h, n, w)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

for h in range(1,3501):
    for n in range(1,3501):
        if 4*h*n - N*n - N*h > 0:
            if (N*h*n / (4*h*n - N*n - N*h)) == (N*h*n // (4*h*n - N*n - N*h)):
                print(h,n,N*h*n // (4*h*n - N*n - N*h))
                sys.exit()

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())

flag=False
def chk(h,n,w,N):
    val1=4*h*n*w
    val2=N*(n*w+h*w+h*n)
    if val1==val2:
        return True
    else:
        return False
def calc(h,n,N):
    if (4*h*n-(n+h)*N)==0:
        return -1
    val=(N*h*n)//(4*h*n-(n+h)*N)
    return val
for h in range(1,3501):
    for n in range(1,3501):
        w=calc(h,n,N)
        if w<=0:
            continue
        else:
            if chk(h,n,w,N):
                ans=[h,n,w]
                print(*ans)
                exit()

Submission status: Accepted

Solution code:
N = int(input())

def func():
    for h in range(1, 3501):
        for n in range(1, 3501):
            temp1 = N * n * h
            temp2 = 4 * h * n - N * (n + h)
            if temp2 != 0:
                w = temp1 // temp2
                if w * temp2 == temp1 and w >= 1:
                    print(h, n, w)
                    return None
func()

Submission status: Accepted

Solution code:
N = int(input())

for h in range(1, 3501):
    for n in range(1, 3501):
        temp1 = N * n * h
        temp2 = 4 * h * n - N * (n + h)
        if temp2 != 0:
            w = temp1 // temp2
            if w * temp2 == temp1 and w >= 1:
                ans = (h, n, w)
                break
h, n, w = ans
print(h, n ,w)

Submission status: Accepted

Solution code:
N = int(input())
for h in range(3501):
    for n in range(h):
        if 4 * h * n - N * (h + n) > 0 and (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: Accepted

Solution code:
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  N=I()
  for h in range(1,3501):
    for n in range(1,3501):
      a=4*h*n-N*n-N*h
      b=N*h*n
      if a<=0:
        continue
      w=b//a

      if b%a==0:
        return str(h)+' '+str(n)+' '+str(w)

# main()
print(main())

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 4/N = 1/h + 1/n + 1/w
# 4*h*n*w = N*(nw+hn+wh) = N*(h+n)*w + N*hn
# (4*h*n - N*(h+n))*w = N*hn

# 4*h*n > N*(h+n)

L=3501
N=int(input())
def solve():
    for h in range(1,L):
        for n in range(1,h):
            d = 4*h*n - N*(h+n)
            if d > 0 and N*h*n % d == 0:
                print(h,n,N*h*n // d)
                return
solve()

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(read())
for i in range(1, 3501):
    for h in range(i, 3501):
        check = 4 * i * h - n * (i + h)
        if check > 0:
            v = n * i * h
            if v % check == 0:
                print(i, h, v // check)
                exit()

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(read())
for i in range(1, 3500):
    for h in range(1, 3500):
        check = 4 * i * h - n * (i + h)
        if check > 0:
            v = n * i * h / check
            if v.is_integer():
                print(i, h, int(v))
                exit()

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def solve(N):
    M = 3501

    for h in range(1, M):
        for n in range(h, M):
            denominator = 4 * n * h - N * h - N * n
            if denominator <= 0:
                continue
            numerator = N * h * n

            if numerator % denominator == 0:
                return h, n, numerator // denominator


def main():
    N = int(input())
    h, n, w = solve(N)
    print(h, n, w)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def solve():
    N = int(input())
    M = 3501

    for h in range(1, M):
        for n in range(h, M):
            numerator = N * h * n
            denominator = 4 * n * h - N * h - N * n
            if numerator <= 0 or denominator <= 0:
                continue
            if numerator % denominator == 0:
                return h, n, numerator // denominator


h, n, w = solve()
print(h, n, w)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#6
#入力
N=int(input())

#処理
import math as m
t=0
for i in range(m.ceil(N/4),m.floor(N*3/4)+1):
    #print(i)
    if 4*i==N:
        continue
    for j in range(m.ceil(N*i/(4*i-N)),m.floor(2*N*i/(4*i-N))+1):
        #print(j)
        if 4*i*j-N*i-N*j==0:
            continue
        k=int((N*i*j)/(4*i*j-N*i-N*j))
        #print(k)
        if 4*i*j*k==N*(i*j+i*k+j*k):
            h=i
            n=j
            t=1
            break
    if t==1:
        break

print(h,n,k)

Submission status: Accepted

Solution code:
#6
#入力
N=int(input())

#処理
import math as m
t=0
for i in range(m.ceil(N/4),m.floor(N*3/4)+1):
    #print(i)
    if 4*i==N:
        continue
    for j in range(m.ceil(N*i/(4*i-N)),m.floor(2*N*i/(4*i-N))+1):
        #print(j)
        if 4*i*j-N*i-N*j==0:
            continue
        k=int((N*i*j)/(4*i*j-N*i-N*j))
        #print(k)
        if 4*i*j*k==N*(i*j+i*k+j*k):
            h=i
            n=j
            t=1
            break
    if t==1:
        break

print(h,n,k)

Submission status: Accepted

Solution code:
import fractions
N = int(input())
for h in range(1,3501):
    for n in range(1, 3501):
        q = 4*n*h-N*(n+h)
        p = n*h*N
        if q <= 0:
            continue
        if p%q==0:
            ans = [h,n,p//q]
print(*ans)

Submission status: Accepted

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=int(w)

        #if w<h:
        #    break

        #print(h,n,w)
        #print(a,b)
        if a%b==0:
            w = a/b
            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: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

n = INT()
for i in range(1, 3501):
    for j in range(i, 3501):
        a = 4 * i * j - (i + j) * n
        b = i * j * n
        if a != 0:
            k = b // a
            if k > 0 and 4 * i * j * k == n * (i * j + j * k + k * i):
                print(i, j, k)
                exit()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    has_answered = False
    for x in range(1, 3501):
        if has_answered:
            break
        for y in range(x, 3501):
            if 4 * x * y - n * y - n * x > 0 and (n * x * y) % (4 * x * y - n * y - n * x) == 0:
                print(x, y, (n * x * y) // (4 * x * y - n * y - n * x))
                has_answered = True
                break


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
from collections import defaultdict, Counter

N = int(input())
for h in range(1, 3501):
    for n in range(1, 3501):
        x = (4*h*n-N*n-N*h)
        if x == 0:
            continue
        w = int(N*n*h/x)
        if w < 1 or 3500 < w:
            continue
        if N*(w*n+h*w+h*n) == 4*h*n*w:
            print(h, n, w)
            exit()