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:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

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


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

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

Submission status: Accepted

Solution code:
n = int(input())
t = 0
for a in range(1, 3501):
    if t != 0:
        break
    for b in range(1, 3501):
        if (4 * a * b - n * (a + b)) != 0:
            if (n * a * b) % (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)))
                t = 1
                break

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

def main():
  N = int(input())
  for h in range(1,3501):
    for n in range(1, 3501):
      d = 4*h*n - N * (h+n)
      if d <= 0:
        continue
      w = (N*h*n) / d
      if w.is_integer():
        print(h, n, int(w))
        return

if __name__=='__main__':
  main()

Submission status: Accepted

Solution code:
N = int(input())

max_num = 3500
for h in range(1,max_num+1):
    for n in range(1, max_num+1):
        if 4*h*n - N*n - N*h <= 0:
            continue
        if N*h*n % (4*h*n - N*n - N*h) == 0:
            w = int(N*h*n / (4*h*n - N*n - N*h))
            Ans = [h, n, w]
            break

print(' '.join(map(str, Ans)))

Submission status: Accepted

Solution code:
N = int(input())
end = False
for h in range(1, 3501):
    if end:
        break
    for n in range(1, 3501):
        if (4 * h * n - N * n - N * h):
            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)
                    end = True
                    break

Submission status: Accepted

Solution code:
N = int(input())
# 2 <= N < 4500　くらいが保証されている

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

Submission status: Accepted

Solution code:
n=int(input())
for a in range(1,3*n//4+1):
    if n>=4*a:
        continue
    b = a
    while True:
        if n*(a+b)>=4*a*b:
            b+=1
            continue
        x = a*b*n
        y = 4*a*b-n*(a+b)
        if y>0 and x%y==0:
            c = x//y
            print("{} {} {}".format(a,b,c))
            exit(0)
        if x/y<b:
            break
        b+=1

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N = int(input())


for h in range(1, 3500+1):
    for w in range(1, 3500 + 1):
        n1 = 4*h*w - h*N - w*N
        if n1:
            l = (h*w*N) / n1
            if 0 < l <= 3500 and int(l) == l:
                print(int(h), int(l), int(w))
                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-n*i-n*j>0:
      if (n*i*j)%(4*i*j-n*i-n*j)==0:
        print(i,j,(n*i*j)//(4*i*j-n*i-n*j))
        exit()

Submission status: Accepted

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

Solution code:
N = int(input())

from math import *

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

Submission status: Accepted

Solution code:
def calc(N, h, n):
    base = 4 * h * n - N * n - N * h
    if base <= 0:
        return False, -1
    ret = (N*h*n) / base
    return ret == int(ret) and 0 <= ret <= 3500, int(ret)

N = int(input())

def f(N):
    for h in range(1, 3501):
        for n in range(1, 3501):
            judge, ret = calc(N,h,n)
            if judge:
                return h, n, ret
    return -1, -1, -1

print(*f(N))

Submission status: Accepted

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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import math
n=int(input())
for a in range(math.ceil(n/4),3501):
    q=4/n-1/a
    if q==0:continue
    for b in range(math.ceil(q),3501):
        if not 4*a*b==b*n+a*n:
            t=a*b*n/(4*a*b-b*n-a*n)
            if t>0 and t%1==0:
                print(a,b,int(t))
                exit()

Submission status: Accepted

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:
        if (N*i*j/(4*i*j-N*i-N*j)).is_integer():
          print(i,j,int((N*i*j/(4*i*j-N*i-N*j))))
          exit()

Submission status: Accepted

Solution code:
import sys

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)))
            sys.exit()

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.buffer.readline

def main():
    N = int(input())
    if N%2 == 0:
        print(N,N,N//2)
    else:
        x,y,z = 0,0,0
        for h in range(1,3501):
            for k in range(h,3501):
                if ((4*h*k-N*(h+k))>0 and (N*h*k)%(4*h*k-N*(h+k)) == 0):
                    x = h
                    y = k
                    z = (N*h*k)//(4*h*k-N*(h+k))
                    break
            if z != 0:
                break
        print(x,y,z)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

N = int(input())
for h in range(math.ceil(N/4),3500+1):
    buff = 4/N-1/h
    if buff==0:
        continue
    for n in range(math.ceil(1/buff),3500+1):
        #print(h,n)
        if 4*h*n-N*h-n*N!=0:
            if (N*h*n)%(4*h*n-N*h-n*N) ==0:
                print(h,n,int(N*h*n/(4*h*n-N*h-n*N)))
                exit()
print("not found")

Submission status: Accepted

Solution code:
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from functools import *
from itertools import permutations,combinations,groupby
import sys
import bisect
import string
import math
import time
import random
def Golf():
    *a,=map(int,open(0))
def S_():
    return input()
def IS():
    return input().split()
def LS():
    return [i for i in input().split()]
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def NI(n):
    return [int(input()) for i in range(n)]
def NI_(n):
    return [int(input())-1 for i in range(n)]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def LtoS(ls):
    return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0}):
#h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage
    mp=[1]*(w+2)
    found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[1]+[mp_def[j] for j in s]+[1]
    mp+=[1]*(w+2)
    return h+2,w+2,mp,found
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['YES','NO']
Yn=['Yes','No']
 
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
#ts=time.time()
#sys.setrecursionlimit(10**7)
input=lambda: sys.stdin.readline().rstrip()
 
def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True

ans=inf


n=I()

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

Submission status: Accepted

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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())
for h in range(1, 3501):
    for n in range(1, 3501):
        y = (4 * h * n - N * (h + n))
        if 0 < y:
            x = (N * h * n)
            w, mod = divmod(x, y)
            if mod == 0:
                print(h, n, w)
                exit()

Submission status: Accepted

Solution code:
# 4/N=1/h+1/n+1/w
# 4w/N-w/h-w/n=1
# w(4/N-1/h-1/n)=1
# w(4hn-Nn-Nh)=Nhn
# w=Nhn/(4hn-Nn-Nh)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

# a >= b >= c を仮定できる
# a,b,c <= 3500
# 4/N <= 3/a  a <= 0.75N
# 4/N >= 3/c  c >= 0.75N

least = int(0.75 * N) + 2
max = 3501
for b in range(1,max):
  for a in range(1,least):
    res = 4/N - 1/a - 1/b
    if res<=0:
      continue
    candc = int(1/res)
    for c in range(candc-1,candc+2):
      if 4*a*b*c == N*(a*b + b*c + c*a):
        print(a,b,c)
        exit(0)

Submission status: Accepted

Solution code:
import sys,collections

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 I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  a=I()

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

main()
# print(main())

Submission status: Accepted

Solution code:
x = int(input())

for h in range(1,4000):
    for n in range(1,4000):
        denom = 4/x - 1/h - 1/n
        if denom == 0:
            continue

        w = 1/denom
        if w < 0 or w > 50000:
            continue
        rounded = round(w)
        gosa = w - rounded
        if abs(gosa) < 10**-10:
            print(h,n,rounded)
            exit()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


class PriorityQueue:
    def __init__(self, l=[]):
        self.__q = l
        heapq.heapify(self.__q)
        return

    def push(self, n):
        heapq.heappush(self.__q, n)
        return

    def pop(self):
        return heapq.heappop(self.__q)


sys.setrecursionlimit(1000000)
MOD = int(1e09) + 7
INF = int(1e15)


def main():
    # sys.stdin = open("Sample.txt")
    N = Scanner.int()
    for h in range(1, 3501):
        for n in range(1, 3501):
            a = N * h * n
            b = 4 * h * n - N * n - N * h
            if b != 0 and a % b == 0:
                w = a // b
                if w > 0:
                    print(h, n, w)
                    return
    return


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

for h in range((N + 3) // 4, 3501):
    for n in range((N + 3) // 4, 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: Accepted

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

    for n in range(1, 3501):
        for h in range(1, 3501):
            b = 4 * h * n - N * n - N * h
            if b > 0:
                w = N * h * n / b
                if w.is_integer():
                    print("{} {} {}".format(n, h, int(w)))
                    exit()

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import numpy as np

N = int(input())
for h in range(1, 3501):
  n = np.arange(1, 3501, dtype=np.int64)
  num = N*h*n
  den = 4*h*n - N*n - N*h
  n = n[(den>0) & (num%den == 0)]
  if len(n) > 0:
    n = n[0]
    w = N*h*n // (4*h*n - N*n - N*h)
    break
print(n, h, w)

Submission status: Accepted

Solution code:
import sys

input_methods=['clipboard','file','key']
input_method=input_methods[1]

bbn=1000000007
	
#+++++

def check(n,h,j):
	#aa = 4*h*j*w - n*h*j - n*j*w - n*w*h
	#aa==0 => 4hjw-njw-nwh == nhj
	t= (4*h*j-n*j-n*h)
	if t!=0 and n*h*j % t == 0:
		#pa((t, n*h*j))
		return (n*h*j)//t
	return -1
	
	#return (4/n)-(1/h + 1/j + 1/w)

		
def main():
	n = int(input())
	#4/N==1/h+1/j+1/w
	#2h==j==w => 4/N==4/2h
	#N = 2h
	
	#4hjw==N(hj+jw+wh)
	#N==4(hjw)/(hj+jw+wh)
	for h in range(1,3501):
		for j in range(1,3501):
			w = check(n,h,j)
			if w > 0:
				#pa(4/n)
				#pa((1/h)+(1/j)+(1/w))
				return ' '.join([str(v) for v in [h,j,w]])
			continue
			
			
			
			#for w in range(1,3501):
			if check(n,h,j,1) > 0:
				break
			if check(n,h,j,3500)<0:
				break
			if check(n,h,j,1)==0:
				return (h,j,1)
			if check(n,h,j,3500)==0:
				return (h,j,3500)
			ok=3500
			ng=0
			while ok-ng>1:
				mid = (ok+ng)//2
				cc= check(n,h,j,mid)
				if cc == 0:
					return (h,j,mid)
				elif cc < 0:
					ng=mid
				else:
					ok=mid
				#print(h,j,w)
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
for n in range(1, 3501):
    for w in range(n, 3501):

        try:
            t = (N*n*w) % (4*n*w - N*w - N*n)
        except:
            continue

        if t == 0 and 4*n*w - N*w - N*n>=0:
            print((N*n*w) // (4*n*w - N*w - N*n), n, w)
            exit()

Submission status: Accepted

Solution code:
n = int(input())

from fractions import Fraction

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

Submission status: Accepted

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

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:
                if (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)
                    return

main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap



@mt
def slv(N):

    for h in range(1, 3501):
        for n in range(1, 3501):
            a = N*h*n
            b = 4*h*n - N*h - N*n
            if b != 0 and a % b == 0 and a // b > 0:
                z = a // b
                return "%d %d %d" % (h, n, z)

def main():
    N = read_int()
    print(slv(N))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
for n in range(1, 3501):
    for h in range(1, 3501):
        a = N*n*h
        b = 4*n*h-N*(n+h)
        if b > 0 and a % b == 0:
            print(n, h, a//b)
            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-n*i-n*j>0 and i*j*n%(4*i*j-n*i-n*j)==0:
            print(i,j,i*j*n//(4*i*j-n*i-n*j))
            exit()

Submission status: Accepted

Solution code:
import sys

if sys.platform in ['ios','win32','darwin']:
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
# coding: utf-8
N = int(input())
for h in range(1, 3501)[::-1]:
    for n in range(1, 3501)[::-1]:
        if 4*h*n-N*(h+n) == 0:
            continue
        w = (N*(h*n)) / (4*h*n-N*(h+n))
        if w != int(w) or w <= 0:
            continue
        w = int(w)
        if 4/N == (n*w+h*w+h*n)/(h*n*w):# and 1 <= h <= 3500 and 1 <= n <= 3500 and 1 <= w <= 3500:
            print(h, n, w)
            exit()

Submission status: Accepted

Solution code:
N = int(input())

h, n, w = 0, 0, 0

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

print(h, n, w)

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

Submission status: Accepted

Solution code:
N=int(input())

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

Submission status: Accepted

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)):
    if (4 / N - 1 / h - 1 / n) <= 0:
        continue
    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: Accepted

Solution code:
N=int(input())

if N%4==0:
    print(3*N//4,3*N//4,3*N//4)
else:
    f=False
    a=(N+3)//4
    while a<=3*N//4:
        if f:
            break
        b=a
        while b<=2*N*a//(4*a-N):
            num=N*a*b
            den=4*a*b-N*(a+b)
            if den<=0:
                b+=1
                continue
            if num%den==0:
                c=num//den
                print(a,b,c)
                f=True
                break
            b+=1
        a+=1

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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:
    l = (N+3)//4
    p = 0
    for i in range(l, 3501):
      m = (N*i)//(4*i-N)+1
      for j in range(m, 3501):
        #print(i, j, (N*i*j)%(4*i*j-N*(i+j)), 4*i*j-N*(i+j))
        if (N*i*j) % (4*i*j-N*(i+j)) == 0 and 4*i*j-N*(i+j) > 0:
          p = 1
          h, n, w = i, j, (N*i*j) // (4*i*j-N*(i+j))
          break
      if p == 1:
        break
print(h, n, w)

Submission status: Accepted

Solution code:
n = int(input())
stop = False
for a in range(1, 3501):
    if stop:
        break
    for b in range(1, 3501):
        p = (n*a*b)
        q = 4*a*b - n*a - n*b
        if q > 0:
            r, s = divmod(p, q)
        
            if s == 0 and r > 0:
                print(a, b, r)
                stop = True
                break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#N=3485
#A=[ 32, 1, 87, 25, 36]
N=int(input())


for i in range(1,3501):
    for j in range(1,3501):
        u=-N*i*j
        d=N*i+N*j-4*i*j
        if(d!=0):
            if(u%d==0 and (u*d > 0)):
                k=u//d
                if(N*(i*j+j*k+k*i)==4*i*j*k):
                    print(i,j,k)
                    exit()