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())
for i in range(1,3501):
    for j in range(1,3501):
        for k in range(1,3501):
            if 4/n == 1/i+1/j+1/k:
                print(i,j,k)
                exit()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

for i in range(1,3500+1):
    for j in range(1,3500+1):
        h = i
        n = j
        
        low = 1
        high = 3500
        
        while low+1 < high:
            mid = (low + high) //2
            
            if 4*h*n*mid >= N*(n*mid+h*n+mid*h):
                high = mid
            else:
                low = mid
                
        if 4*h*n*high == N*(n*high+h*n+high*h):
            print(h,n,high)
            exit()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
for h in range(3500):
  for n in range(3500):
    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: Time Limit Exceeded

Solution code:
import math
const=3500+1
N = int(input())
ans=4/N
flg=False
for h in range(1,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: Time Limit Exceeded

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*3501; diff_num = N*h
    dem = 4*h*3501 - N*(h+3501); diff_dem = 4*h - N
    for n in range(3500, -1, -1):
      num -= diff_num
      dem -= diff_dem
      if dem <= 0:
        break
      if num%dem == 0:
        print(h, n, num//dem)
        quit()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

if N%2 == 0:
  print(N, N, N//2)
else:
  for h in range(1, 3501):
    for n in range(1, 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: 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:
      continue
    w = N*h*n/(4*n*h-N*n-N*h)
    if w > 0 and w.is_integer():
      ans = [n, h, int(w)]
print(*ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

for h in range(1, 3500+1):
  for n in range(1, 3500+1):
    if 4*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: Time Limit Exceeded

Solution code:
from fractions import Fraction
N = int(input())
for h in range(1, 3501):
    for n in range(1, 3501):
        w1 = 4 / N - (1 / h + 1 / n)
        w = Fraction(w1)
        de = w.denominator
        nu = w.numerator
        if w1 > 0 and de % nu == 0:
            print(h, n, de // nu)
            exit()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

N = 4/N
flg = False
for h in range(1,3500):
    if not flg:
        for n in range(h,3500):
            if N*h*n == (n+h) + 1:
                print(h,n,n*h)
                flg = True
                break
    else:
        break

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

N = 4/N

for h in range(1,3500):
    for n in range(h,3500):
        if N*h*n == (n+h) + 1:
            ans = [h,n,n*h]
            break
            
print(ans[0],ans[1],ans[2])

Submission status: Time Limit Exceeded

Solution code:
MOD = 10 ** 9 + 7
INF = 10 ** 10
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)

def main():
    n = int(input())
    if n%2 == 0:
        print(n//2,n,n)
        return
    for i in range(1,3501):
        for j in range(i + 1,3501):
            if (n * i * j)%(4 * i * j - n * j - n * i) == 0:
                ans = (i ,j , (n * i * j)//(4 * i * j - n * j - n * i))
                break
    
    print(*ans)

if __name__ =='__main__':
    main()

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+b) != 0:
            r = (N*a*b) % ( (4*a*b) - N*(a+b) )
            if r == 0:
                c = (N*a*b) // ( (4*a*b) - N*(a+b) )
                if c > 0:
                    break
    else:
        continue
    break
print(a,b,c)

Submission status: Time Limit Exceeded

Solution code:
#Tenka1_C
N = int(input())
def solve(h, n):
    x = N * h * n
    y = 4 * h * n - N * (n + h)
    if y <= 0:
        return -1
    if x % y == 0:
        return x // y
    else:
        return -1
    
flg = False
for h in range(1, 3501):
    if flg: break
    for n in range(1, 3501):
        if flg: break
        if solve(h, n) != -1:
            print(h, n, solve(h, n))
            flg = True

Submission status: Time Limit Exceeded

Solution code:
import sys
N = int(input())
for h in range(1,3501):
    for n in range(1,3501):
        tmp = 4*h*n-N*(n+h)
        if tmp == 0:
            continue
        d,m = divmod(N*h*n, tmp)
        if m == 0 and d > 0:
            print(h,n,d)
            sys.exit()

Submission status: Time Limit Exceeded

Solution code:
from itertools import combinations

N = int(input())

for h, n in combinations(range(1, 3501), 2):
    num = N * h * n
    denom = 4 * h * n - N * n - N * h
    if denom > 0 and num % denom == 0:
        w = num // denom
        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):
        num = N * h * n
        denom = 4 * h * n - N * n - N * h
        if denom > 0 and num % denom == 0:
            w = num // denom
            break
    else:
        continue
    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(h,3501):
        wd = 4*h*n - n*N - h*N
        wu = N*h*n
        if wd > 0 and wu % wd == 0:
            w = wu // wd
            print(h,n,w)
            exit()

Submission status: Time Limit Exceeded

Solution code:
import math
N = int(input())
flag = False
for h in range(1, 3501, 1):
    for n in range(1, 3501, 1):
        bumbo = 4 * h * n - N * h - N * n
        bunshi = N * h * n
        if bumbo == 0:
            continue
        wc = math.ceil(bunshi / bumbo)
        wf = math.floor(bunshi / bumbo)
        if wc == wf and wc >= 1:
            ans_h = h
            ans_n = n
            ans_w = wc
            flag = True
            break
    if flag:
        break
print(ans_h, ans_n, ans_w)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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-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)
        if w>0:
          print(h,n,w)
          flag=False
          break
  if flag==False:
    break

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int):
    for i in range(1, 3501):
        for j in range(i, 3501):
            z = 4*i*j - N*(j+i)
            if z != 0:
                h, r = divmod((N*i*j), z)
                if r == 0 and 0 <= h:
                    print(h, i, j)
                    exit()
            

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


# #!/usr/bin/env python3
# n = int(input())
# for i in range(1, 3501):
#   for j in range(1, 3501):
#     seed = 4 * i * j - n * (i + j) 
#     if seed > 0:
#       k, mod = divmod(n * i * j, seed) 
#       if mod == 0:
#         print(i, j, k)
#         exit()

Submission status: Time Limit Exceeded

Solution code:

# def solve(N: int):
#     for i in range(1, 3501):
#         for j in range(1, 3501):
#             z = 4*i*j - N*j - N*i
#             if z != 0:
#                 h, r = divmod((N*i*j), z)
#                 if r == 0 and 0 <= h:
#                     print(h, i, j)
#                     exit()
            

#     return

N = int(input())
# solve(N)

for i in range(1, 3501):
    for j in range(1, 3501):
        z = 4*i*j - N*j - N*i
        if z != 0:
            h, r = divmod((N*i*j), z)
            if r == 0 and 0 <= h:
                print(h, i, j)
                exit()
            


# # Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
# def main():
#     def iterate_tokens():
#         for line in sys.stdin:
#             for word in line.split():
#                 yield word
#     tokens = iterate_tokens()
#     N = int(next(tokens))  # type: int
#     solve(N)

# if __name__ == '__main__':
#     main()

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
# import sys


def solve(N: int):
    for i in range(1, 3501):
        for j in range(1, 3501):
            z = 4*i*j - N*j - N*i
            if z != 0:
                h, r = divmod((N*i*j), z)
                if r == 0 and 0 <= h:
                    print(h, i, j)
                    exit()
            

    return

N = int(input())
solve(N)


# # Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
# def main():
#     def iterate_tokens():
#         for line in sys.stdin:
#             for word in line.split():
#                 yield word
#     tokens = iterate_tokens()
#     N = int(next(tokens))  # type: int
#     solve(N)

# if __name__ == '__main__':
#     main()

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int):
    for i in range(1, 3501):
        for j in range(i, 3501):
            z = 4*i*j - N*j - N*i
            if z != 0:
                h, r = divmod((N*i*j), z)
                if r == 0 and 0 <= h:
                    print(h, i, j)
                    exit()
            

    return

N = int(input())
solve(N)


# # Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
# def main():
#     def iterate_tokens():
#         for line in sys.stdin:
#             for word in line.split():
#                 yield word
#     tokens = iterate_tokens()
#     N = int(next(tokens))  # type: int
#     solve(N)

# if __name__ == '__main__':
#     main()

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int):
    for i in range(1, 3501):
        for j in range(i, 3501):
            # dN, di, dj = Decimal(N), Decimal(i), Decimal(j)
            z = 4*i*j - N*j - N*i
            if z != 0:
                h, r = divmod((N*i*j), z)
                if r == 0 and 0 <= h:
                    print(h, i, j)
                    exit()
            

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int):
    for i in range(1, 3501):
        for j in range(i, 3501):
            if (4*i*j - N*j - N*i) == 0:
                continue
            h, r = divmod((N*i*j), 4*i*j - N*j - N*i)
            if r == 0 and 0 <= h:
                print(h, i, j)
                exit()
            

    return

N = int(input())
solve(N)

# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
# def main():
#     def iterate_tokens():
#         for line in sys.stdin:
#             for word in line.split():
#                 yield word
#     tokens = iterate_tokens()
#     N = int(next(tokens))  # type: int
#     solve(N)

# if __name__ == '__main__':
#     main()

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int):
    for i in range(1, 3501):
        for j in range(i, 3501):
            # dN, di, dj = Decimal(N), Decimal(i), Decimal(j)
            if (4*i*j - N*j - N*i) == 0:
                continue
            h, r = divmod((N*i*j), 4*i*j - N*j - N*i)
            if r == 0 and 0 <= h:
                print(h, i, j)
                exit()
            

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int):
    for i in range(1, 3501):
        for j in range(i, 3501):
            # dN, di, dj = Decimal(N), Decimal(i), Decimal(j)
            z = 4*i*j - N*j - N*i
            if z == 0:
                continue
            h, r = divmod((N*i*j), z)
            if r == 0 and 0 <= h <= 3500:
                print(h, i, j)
                exit()
            

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int):
    from decimal import Decimal
    for i in range(1, 3501):
        for j in range(1, 3501):
            dN, di, dj = Decimal(N), Decimal(i), Decimal(j)
            z = 4*di*dj - dN*dj - dN*di
            if z == 0:
                continue
            h = (dN*di*dj)/z
            if 0 <= h <= 3500:
                print(h, i, j)
                exit()
            

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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 - a*N - b*N != 0:
            if a*b*N // (4*a*b - a*N - b* N) > 0 and a*b*N % (4*a*b - a*N - b* N) ==0:
                c = int(a*b*N / (4*a*b - a*N - b* N))
                print(a, b, c)
                flag = 1
                break

Submission status: Time Limit Exceeded

Solution code:
# Author: cr4zjh0bp
# Created: Sat Mar 14 14:07:54 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

N = ni()
m = 3500 // 4

def f():
    ans = []
    for h in range(3501):
        for n in range(3501):
            c = h * n * N
            d = 4 * h * n - N * n - N * h
            if d > 0 and c % d == 0:
                ans = [h, n, c // d]
                return ans

print(*f())

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
for i in range(3500):
    for j in range(3498):
        try:
            a=i+1 ; b=j+1
            t=(a*b*n)/(4*a*b-b*n-a*n)
            if t>0 and t%1<0.0000000001:
                print(a,b,int(t))
                exit()
        except ZeroDivisionError:
            continue

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
if N%2==0:
  print(N//2,N,N)
else:
  for i in range(1,3501):
    for j in range(1,3501):
      if 4*i*j-N*i-N*j!=0:
        w=(N*i*j)/(4*i*j-N*i-N*j)
        if w>0 and w.is_integer():
          print(i,j,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):
        a = N * h * n
        b = 4 * h * n - N * (h + n)
        if a > 0 and b > 0 and a % b == 0:
            print("{0} {1} {2}".format(h, n, a//b))
            exit()

Submission status: Time Limit Exceeded

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

    for n in range(1, 3501):
        for h 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:
                    print("{} {} {}".format(n, h, int(w)))
                    exit()

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 3*i*j == n * (i+j):
      print(n,i,j)
      exit()

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

from fractions import Fraction

for i in range(1,3501):
    for j in range(i,3501):
        k = Fraction(4, n) - Fraction(1, i) - Fraction(1, j)
        if k < 0:
            continue
        if k.numerator == 1:
            print(i, j, k.denominator)
            import sys
            sys.exit()

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

from fractions import Fraction

for i in range(1,3501):
    for j in range(i,3501):
        k = Fraction(4, n) - Fraction(1, i) - Fraction(1, j)
        if k.numerator == 1:
            print(i, j, k.denominator)
            import sys
            sys.exit()

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

from fractions import Fraction

for i in range(1,3501):
    for j in range(1,3501):
        k = Fraction(4, n) - Fraction(1, i) - Fraction(1, j)
        if k.numerator == 1:
            print(i, j, k.denominator)
            import sys
            sys.exit()

Submission status: Time Limit Exceeded

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: continue
            if (N*h*n)%(4*h*n-N*h-N*n) == 0:
                w = (N*h*n)//(4*h*n-N*h-N*n)
                if w > 0:
                    print(h,n,w)
                    return

main()

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
for i in range(1,3501):
    for j in range(1,3501):
        t1=n*i*j
        t2=4*i*j-n*i-n*j
        if t2>0:
            k,m=divmod(t1,t2)
            if k>0 and m==0:
                print(i,j,k)
                exit()

Submission status: Time Limit Exceeded

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

for i in range(1, 3501):
    for j in range(1, 3501):
        tmp1 = N * i * j
        tmp2 = (4 * i * j) - (N * j) - (N * i)
        if tmp2 != 0:
            s, m = divmod(tmp1, tmp2)
            if m == 0 and s >= 0:
                n, h, w = i, j, s
                print(n, h, w)
                exit()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# https://atcoder.jp/contests/tenka1-2017/tasks/tenka1_2017_c
# 式をこねくり回せ

N = int(input())

from itertools import product

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
if N % 4 == 0:
  h, n, w = (3 * N) // 4, (3 * N) // 4, (3 * N) // 4
elif N % 4 == 2:
  h, n, w = N, N, N // 2
elif N % 4 == 3:
  s = N // 4 + 1
  h, n, w = 2 * s, 2 * s, s * N
elif N % 4 == 1:
  s = (N // 4) + 1
  if s % 3 == 0:
    h = s
    n = 2 * (s // 3) * (4 * s - 3)
    w = 2 * (s // 3) * (4 * s - 3)
  elif s % 3 == 2:
    h = N
    n = 4 * (s // 3) + 2
    w = (4 * (s // 3) + 2) * (12 * (s // 3) + 5)
  elif s % 3 == 1:
    for i in range(1, 3501):
      for j in range(1, 3501):
        if (N * i * j) / (4 * i * j - N * i - N * j) == int((N * i * j) / (4 * i * j - N * i - N * j)):
          h, n, w = i, j, int((N * i * j) / (4 * i * j - N * i - N * j))
          break
print(h, n, w)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
N = int(stdin.readline().rstrip())
for h in range(1,3501):
    for n in range(1,3501):
        if (4*h*n-N*h-N*n) != 0:
            w = (N*h*n)/(4*h*n-N*h-N*n)
        else:
            continue
        if w.is_integer() and w > 0:
            print(h,n,int(w))
            break
    else:
        continue
    break

Submission status: Time Limit Exceeded

Solution code:
# おなじみ 1/w = ...の形からもっていくとw = ..が導出できた

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())

high=3500
low=1

for i in range(1,3501):
    for j in range(i,3501):
        while high-low>1:
            k=(high+low)//2
            x=4*(i*j*k)/(i*j+j*k+k*i)
            if n==x:
                print(i,j,int(k))
                exit()
                
            elif n>x:
                low=x                
            else:
                high=x

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
for h in range(1, 3501):
    for n in range(1, 3501):
        # 4/N - 1/h - 1/n = 1/w
        # (4hn - Nn - Nh) / nhN = 1/w
        # w = nhN / (4hn - Nn - Nh)

        if (4*h*n - N*(n + h)) != 0 and (n*h*N) % (4*h*n - N*(n + h)) == 0:
            w = (n*h*N) // (4*h*n - N*(n + h))
            if w > 0:
                print(h, n, w)
                exit(0)

Submission status: Time Limit Exceeded

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

            st,end=n,3500
            for w in [st,end]:
                B=4*h*n*w-(n*w+h*w+h*n)*N
                if B==0:
                    flag=1
                    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:
import sys
N=int(input())

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

Submission status: Time Limit Exceeded

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

            st,end=n,3500
            for w in [st,end]:
                B=4*h*n*w-(n*w+h*w+h*n)*N
                if B==0:
                    flag=1
                    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())
sep_n = 1.0/3500.0
a=4.0/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 - sep_n >=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:
                w=int((st+end)*0.5)
                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
h_st=int(N*(1/4))
h_st=1
for h in range(h_st,3501):
    H=1/h
    for n in range(h,3501):
        flag=0
        if a-H-1/n-1/n<=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
#h_st=int(N*(2/4))
h_st=1
for h in range(h_st,3501):
    H=1/h
    for n in range(h,3501):
        flag=0
        if a-H-1/n-1/n<=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)