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:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines

def main():
    N = int(input())
    for h in range(1, 3501):
        for n in range(1, 3501):
            shisu = h * N * n
            bosu = n * (h * 4 - N) - h * N
            if bosu >= 1:
                if not (shisu / bosu) % 1:
                    print(h, n , int((h * N * n) / (n * (h * 4 - N) - h * N)))
                    sys.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):
    if 4*h*n-N*n-N*h!=0:
      w=(N*n*h)/(4*h*n-N*n-N*h)
      if int(w)==w and w>0:
        print(h,n,int(w))
        exit()

Submission status: Accepted

Solution code:
N = int(input())
mx = 3503
found = False
for i in range(1, mx):
    for j in range(1, mx):
        if i*j*4 % N != 0:
            continue
        den = ((i*j*4)//N) - i - j
        num = i*j
        if den == 0:
            continue
        if num%den == 0 and num//den > 0 and num//den < mx:
            print(i,j,num//den)
            found = True
            break
    if found:
        break

Submission status: Accepted

Solution code:
import sys, math
from functools import lru_cache
from collections import defaultdict
from decimal import Decimal
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    N = ii()
    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 w > 0:
                print(h, n, int(w))
                return

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    for h in range(1, 3501):
        denominator = 4*h - N
        numerator = N*h
        if denominator > 0:
            n = (numerator//denominator) + 1
            denominator = 4*h*n - N*(h+n)
            numerator = N*h*n
            if denominator > 0 and numerator % denominator == 0:
                print(h, n, numerator//denominator)
                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):
            denominator = 4*h*n - N*n - N*h
            if denominator <= 0:
                continue
            w = (N*h*n)/denominator
            if w % 1 == 0:
                print(h, n, int(w))
                exit()


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())
import sys
for i in range(1, 3501):
    for j in range(1, 3501):
        w_t = n*i*j
        w_u = 4*i*j - i*n -j*n
        if w_u > 0:
            w = w_t/w_u
            if w.is_integer():
                print("%s %s %s" % (i, j, int(w)))
                sys.exit()

Submission status: Accepted

Solution code:
N=int(input())
    
for i in range(1,3500):
    for j in range(1,3500):
        a=N*i*j
        b=4*i*j-N*j-N*i
        if b>0:
            if (a/b).is_integer()==True:
                print(i,j,int(a/b))
                exit()

Submission status: Accepted

Solution code:
# coding: utf-8
import math
n=int(input())
flg=False
for i in range(1, 3501):
    for j in range(1, 3501):
        a=i
        b=j
        if 4*a*b-n*(a+b)!=0:
            c=n*a*b/(4*a*b-n*(a+b))
            if c==int(c) and c>0:
                c=int(c)
                flg=True
                break
    if flg:
        break
print(a,b,c)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from numba import njit, i8
import numpy as np


@njit(i8[:](i8))
def solve(N):
    # 4 * h * n * w == N * (h * n + n * w + w * h)
    for i in range(3501):
        for j in range(3501):
            num = N * i * j
            den = 4 * i * j - N * (i + j)
            if den <= 0:
                continue
            if num % den == 0:
                return np.array((i, j, num // den), dtype=np.int64)
    return np.zeros(3, dtype=np.int64)


print(*solve(int(input())))

Submission status: Accepted

Solution code:
N = int(input())
flag = 0

for h in range(1,3500):
    for n in range(1,3500):
        x = 4*h*n
        y = N*(h+n)
        if x<=y:
            continue
        tmp = (N*h*n)/(x-y)
        if tmp.is_integer():
            print(h,n,int(tmp))
            flag = 1
            break
    if flag == 1:
        break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
for h in range(max(1, int(n / 4)), min(3500, int(3*n / 4)) + 1):
    for w in range(max(1, int(3*n / 4)), 3501):
        num = n * h * w
        den = 4 * h * w - n * (h + w)
        if den != 0 and num % den == 0 and h <= num // den <= w:
            print(h, num // den, w)
            exit()

Submission status: Accepted

Solution code:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
  return int(readline())
N = I()
for n in range(1,3501):
    for h in range(1,3501):
        if 4*n*h - N*(h+n) != 0:
            ans = n*h*N / (4*n*h-N*(h+n))
            if ans < 1:
                continue
            if int(ans) == ans:
                print(h,n,int(ans))
                exit()

Submission status: Accepted

Solution code:
N = int(input())
flag = 0
for h in range(1,3501):
    for w in range(1,3501):
        if 4*h*w-N*w-N*h>0 and (N*h*w)%(4*h*w-N*w-N*h)==0:
            x = h
            y = w
            z = (N*h*w)//(4*h*w-N*w-N*h)
            flag = 1
            break
    if flag==1:break
print(x,y,z)

Submission status: Accepted

Solution code:
N = int(input())
# 4 * h * n * w == N * (h * n + n * w + w * h)
for i in range(3501):
    for j in range(3501):
        num = N * i * j
        den = 4 * i * j - N * (i + j)
        if den <= 0:
            continue
        if num % den == 0:
            print(i, j, num // den)
            exit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
def I(): return int(sys.stdin.readline().rstrip())

N = I()
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())
flag = 0
for h in range(1,3500):
    for n in range(1,3500):
        a = 4*h*n-N*(h+n)
        if a>0 and (N*h*n)%a==0:
            w = (N*h*n)//a
            flag = 1
            break
    if flag==1:break
if flag==1:
    print(h,n,w)
else:
    print()

Submission status: Accepted

Solution code:
import sys
 
N = int(sys.stdin.readline())
 
# 4*h*n*w = N * (h*n + n*w + w*h)
# (4*h*n - N*n - N*h) * w = N*h*n
# w = N*h*n / (4*h*n - N*n - N*h)
 
for h in range(1, 3501):
    for n in range(1, 3501):
        a = N*h*n
        b = (4*h*n - N*n - N*h) 
        # print(h, n, a, b)
        if b > 0 and a % b == 0:
            w = a // b
            # print(4/N, 1/h + 1/n + 1/w)
            print(h, n, w)
            sys.exit()

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

N = I()
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:
import sys

n = int(input())

for i in range(1, 3500):
    for j in range(1, 3500):
        rest = 4 * i * j - (i + j) * n
        if rest > 0:
            ans = n * i * j / rest
            if ans.is_integer():
                print(i, j, int(ans))
                sys.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)) != 0:
            w = N*h*n/(4*h*n-N*(h+n))
            if float.is_integer(w) and w > 0:
                print(h, n, int(w))
                exit()

Submission status: Accepted

Solution code:
N = int(input())

for a in range(1,3501):
    for b in range(1,3501):
        x = a*b*N
        y = 4*a*b - b*N - a*N
        if y != 0 and x/y > 0:
            c = x//y
            if 4*a*b*c == b*c*N + a*c*N + a*b*N:
                print(a,b,c)
                exit()

Submission status: Accepted

Solution code:
import sys
N=int(input())
for h in range(1,3501):
  for n in range(h,3501):
    if 4*h*n-N*n-h*N>0 and (N*h*n)%(4*h*n-N*n-h*N)==0:
      ans=[]
      ans.append(str(h))
      ans.append(str(n))
      ans.append(str((N*h*n)//(4*h*n-N*n-h*N)))
      print(' '.join(ans))
      sys.exit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())    

for h in range(1,3501):
    for n in range(h,3501):
        top = N*h*n
        bottom = 4*h*n-N*n-N*h
        if bottom > 0 and top%bottom == 0:
            print(h,n,top//bottom)
            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>0 and (h*n*N)%(4*h*n-(n+h)*N)==0:
            print(n,h,(h*n*N)//(4*h*n-(n+h)*N))
            exit()

Submission status: Accepted

Solution code:
N=int(input())

for h in range(1,3500+1):
    for n in range(1,3500+1):
        try:
            if (N*h*n)%(4*h*n-N*(h+n))==0 and (4*h*n-N*(h+n))>0:
                A,B,C=h,n,(N*h*n)//(4*h*n-N*(h+n))
        except:
            pass
print(A,B,C)

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>0 and i*j*n/(4*i*j-n*j-n*i)%1==0:
      print(i,j,int(i*j*n/(4*i*j-n*j-n*i)))
      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-N*h != 0:
            w,r = divmod(N*h*n,4*h*n-N*n-N*h)
            if r == 0 and w > 0:
                print(h,n,w)
                sys.exit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(readline())

    for a in range(1, 3501):
        for b in range(1, 3501):
            nu = n * a * b
            dn = 4 * a * b - n * (a + b)
            if dn > 0 and nu % dn == 0:
                return print(a, b, nu // dn)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


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

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
for i in range(1,3500+1):
    for j in range(1,3500+1):
        divided=n*i*j
        divider=4*i*j-n*(i+j)
        if divider>0 and divided%divider==0:
            print(i,j,divided//divider)
            sys.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-N*h==0:
            continue
        if N*h*n%(4*h*n-N*n-N*h)==0:
            w=N*h*n//(4*h*n-N*n-N*h)
        else:
            continue
        if 4*h*n*w==N*(n*w+h*w+h*n) and w>0:
            print(h,n,w)
            exit()

Submission status: Accepted

Solution code:
#  very slow solution
def main():
	N = int(input())
	for n in range(1, 3502):
		for h in range(1,3502):
			t = n*h*N
			p = 4*n*h-(n*N+h*N)
			if p>0 and t%p==0:
				w = t//p
				print(n , h, w)
				exit()


if __name__=="__main__":
	main()

Submission status: Accepted

Solution code:

def main():
	N = int(input())
	for n in range(1, 3502):
		for h in range(1,3502):
			t = n*h*N
			p = 4*n*h-(n*N+h*N)
			if p>0 and t%p==0:
				w = t//p
				print(n , h, w)
				exit()


if __name__=="__main__":
	main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n=int(input())

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

Submission status: Accepted

Solution code:
N = int(input())
for ai in range(N//4,3500):
    for bi in range(N//4,3500):
        try:
            ci = N*ai*bi/(4*ai*bi-N*ai-N*bi)
        except:
            continue
        if ci == int(ci) and ci > 0:
            print(ai,bi,int(ci))
            exit()

Submission status: Accepted

Solution code:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()

    if N % 2 == 0:
        print(N, N, N // 2)
    else:
        ans = (0, 0, 0)
        for h in range(1, 3501):
            for n in range(h, 3501):
                # 式をwについて解いた
                num = N * n * h
                denom = 4 * h * n - N * (h + n)
                if denom > 0 and num % denom == 0:
                    w = num // denom
                    ans = (h, n, w)
                    break

        print(*ans)

if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
N = int(input())

def f(n):
    res = []
    i = 1
    while i <= n**0.5:
        if n%i == 0:
            res.append(n)
            if N//i > i:
                res.append(N//i)
        i += 1
    return res

num = 4
if N%4 == 0:
    num = 1
    N //= 4
elif N%2 == 0:
    num = 2
    N //= 2

P = f(N)
P.sort(reverse=True)
ans = []
for p in P:
    i = 1
    while p*i <= 3500:
        Q = f(N//p)
        for q in Q:
            j = 1
            while q*j <= 3500:
                if num*p*i*q*j-(p*i+q*j)*N > 0 and ((p*i)*(q*j)*N)%(num*p*i*q*j-(p*i+q*j)*N) == 0:
                    ans = [p*i, q*j, ((p*i)*(q*j)*N)//(num*p*i*q*j-(p*i+q*j)*N)]
                    i = 4000
                    j = 4000
                j += 1
            if len(ans) > 0:
                break
        i += 1
    if len(ans) > 0:
        break

print(*ans)

Submission status: Accepted

Solution code:
import sys
import math
import copy
import heapq
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter
sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = float("inf")
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)

def nck(n, k, kaijyo):
    return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD

def npk(n, k, kaijyo):
    if k == 0 or k == n:
        return n % MOD
    return (kaijyo[n] * divide(kaijyo[n-k])) % MOD

def fact_and_inv(SIZE):
    inv = [0] * SIZE  # inv[j] = j^{-1} mod MOD
    fac = [0] * SIZE  # fac[j] = j! mod MOD
    finv = [0] * SIZE  # finv[j] = (j!)^{-1} mod MOD
    inv[1] = 1
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    for i in range(2, SIZE):
        inv[i] = MOD - (MOD // i) * inv[MOD % i] % MOD
        fac[i] = fac[i - 1] * i % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD

    return fac, finv

def renritsu(A, Y):
    # example 2x + y = 3, x + 3y = 4
    # A = [[2,1], [1,3]])
    # Y = [[3],[4]] または [3,4]
    A = np.matrix(A)
    Y = np.matrix(Y)
    Y = np.reshape(Y, (-1, 1))
    X = np.linalg.solve(A, Y)

    # [1.0, 1.0]
    return X.flatten().tolist()[0]

class TwoDimGrid:
    # 2次元座標 -> 1次元
    def __init__(self, h, w, wall="#"):
        self.h = h
        self.w = w
        self.size = (h+2) * (w+2)
        self.wall = wall
        self.get_grid()
        # self.init_cost()

    def get_grid(self):
        grid = [self.wall * (self.w + 2)]
        for i in range(self.h):
            grid.append(self.wall + getS() + self.wall)

        grid.append(self.wall * (self.w + 2))
        self.grid = grid
    def init_cost(self):
        self.cost = [INF] * self.size

    def pos(self, x, y):
        # 壁も含めて0-indexed 元々の座標だけ考えると1-indexed
        return y * (self.w + 2) + x
    def getgrid(self, x, y):
        return self.grid[y][x]
    def get(self, x, y):
        return self.cost[self.pos(x, y)]
    def set(self, x, y, v):
        self.cost[self.pos(x, y)] = v
        return
    def show(self):
        for i in range(self.h+2):
            print(self.cost[(self.w + 2) * i:(self.w + 2) * (i+1)])
    def showsome(self, tgt):
        for t in tgt:
            print(t)
        return
    def showsomejoin(self, tgt):
        for t in tgt:
            print("".join(t))
        return

    def search(self):
        grid = self.grid
        move = [(0, 1), (0, -1), (1, 0), (-1, 0)]
        move_eight = [(0, 1), (0, -1), (1, 0), (-1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
        # for i in range(1, self.h+1):
        #     for j in range(1, self.w+1):
        #         cx, cy = j, i
        #         for dx, dy in move_eight:
        #             nx, ny = dx + cx, dy + cy

def solve():
    n = getN()
    for a in range(1, 3501):
        for b in range(a, 3501):
            if (4 * a * b / n) - b - a == 0:
                continue
            c = round((a * b) / ((4 * a * b / n) - b - a))
            if c <= 0:
                continue
            if n * (a * b + b * c + c * a) == 4 * a * b * c:
                print(a,b,c)
                return
def main():
    n = getN()
    for _ in range(n):
        solve()

    return
if __name__ == "__main__":
    # main()
    solve()

Submission status: Accepted

Solution code:

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

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




                
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    for a in range(1, 3501):
        for b in range(1, 3501):
            L = 4*a*b - (a+b)*N
            R = a*b*N
            if L <= 0:
                continue
            if R % L == 0:
                c = R // L
                print(a, b, c)
                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):
        try:
            w = (N * h * n) / (4 * (h * n) - (N * n) - (N * h))
        except:
            continue
        if w.is_integer() and w > 0:
            if 4 * (h * n * w) == N * ((n * w) + (h * w) + (h * n)):
                ans = [h, n, int(w)]
                exit(print(' '.join(map(str, ans))))

Submission status: Accepted

Solution code:


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


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    """
    h, n, w <= 3500
    4/N = 1/h+1/n+1/w
    1/h = 4/N-1/n-1/w = 4nw-Nw-Nn / Nnw
    """
    N = read_int()
    for w in range(1, 3501):
        for n in range(1, 3501):
            if (4*n*w-N*w-N*n) != 0 and (N*n*w)%(4*n*w-N*w-N*n) == 0:
                h = (N*n*w)//(4*n*w-N*w-N*n)
                if h > 0:
                    return h, n, w


if __name__ == '__main__':
    print(*solve())

Submission status: Accepted

Solution code:
N = int(input())
# 4/n = 1/h+1/n+1/w
for h in range(1,3501):
  for n in range(h,3501):
    w1 = N*h*n
    w2 = 4*h*n-N*n-N*h
    if w2 == 0:
      continue
    if w1%w2 == 0:
      w = w1//w2
      if w > 0:
        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):
    a = (4 * h * n) - N * h - N * n
    if a <= 0:
      continue
    w = (N * h * n) / a
    if w.is_integer() and 0 < w:
      print(h, n, int(w))
      exit(0)

Submission status: Accepted

Solution code:
N = int(input())

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

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

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    # 4hnw = N(hn + nw + wh)
    # (4hn - N(n + h)) w = Nhn
    for h in range(1, 3501):
        for n in range(1, 3501):
            d = 4 * h * n - N * (n + h)
            if d <= 0 or (N * h * n) % d != 0 or (N * h * n) // d > 3500:
                continue
            w = (N * h * n) // d
            print(h, n, w)
            return


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()

for h in range(1, 3501):
    for m in range(h, 3501):
        if 4*h*m-n*m-n*h > 0 and n*h*m % (4*h*m-n*m-n*h) == 0:
            w = (n*h*m)//(4*h*m-n*m-n*h)
            print(h, m, 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 - N*h != 0:
      w = (N*h*n)/(4*h*n - N*n - N*h)
    else:
      continue
    if w > 0 and w == int(w):
      print(h,n,int(w))
      exit()

Submission status: Accepted

Solution code:
def main():
    import sys
    sys.setrecursionlimit(10**6)
    input = sys.stdin.readline
    N = int(input())
    for h in range(1, 3501):
        if N >= 4 * h:
            continue
        for n in range(h, 3501):
            if N * (h + n) >= 4 * h * n:
                continue
            t1 = N * h * n
            t2 = 4 * h * n - N * n - N * h
            if t1 % t2 == 0:
                print(h, n, t1 // t2)
                return True

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

N = int(sys.stdin.readline())

# 4*h*n*w = N * (h*n + n*w + w*h)
# (4*h*n - N*n - N*h) * w = N*h*n
# w = N*h*n / (4*h*n - N*n - N*h)

for h in range(1, 3501):
    for n in range(1, 3501):
        a = N*h*n
        b = (4*h*n - N*n - N*h) 
        # print(h, n, a, b)
        if b > 0 and a % b == 0:
            w = a // b
            # print(4/N, 1/h + 1/n + 1/w)
            print(h, n, w)
            sys.exit()
else:
    print("something wrong")

Submission status: Accepted

Solution code:
def main():
  N = int(input())
  flag = False
  for i in range(1, 3501):
    for j in range(1, 3501):
      if 4*i*j-N*i-N*j > 0 and N*i*j % (4*i*j-N*i-N*j) == 0:
        print(i, j, int(N*i*j/(4*i*j-N*i-N*j)))
        flag = True
        break
    if flag:
      break
        
if __name__ == "__main__":
  main()

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*N <= 0:
      continue
    if N*h*n % (4*h*n-n*N-h*N) == 0:
      w = N*h*n // (4*h*n-n*N-h*N)
      print("{} {} {}".format(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-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())

# h <= 3N/4 <= N
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 (N * h * n) % (4 * h * n - N * n - N * h) == 0 and w > 0:
            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):
        A=4*h*n-N*n-N*h
        B=N*h*n
        if A>0:
            if B%A==0:
                print(h,n,B//A)
                break
    else:
        continue
    break

Submission status: Accepted

Solution code:
from math import floor
from sys import exit

def isinteger(n):
    if isinstance(n,int):
        return True
    if isinstance(n,float):
        return n.is_integer()
    return False

n = int(input())
for i in range(floor(1700*n/(7000-n)-1),floor(3*n/4)+2):
    if 14000*i != (3500+i)*n and 4*i != n:
        mini = 3500*n*i/(14000*i-(3500+i)*n)
        maxi = 2*n*i/(4*i-n)
        for j in range(floor(mini)-1,floor(maxi)+2):
            if i!=0 and j!=0 and 4/n != 1/i+1/j:
                w = 1/(4/n-1/i-1/j)
                if abs(w-round(w))<=10**(-8) and 3500>=w>=1 and j >= 1 and i >= 1:
                    exit(print(i,j,round(w)))
            else:
                continue
    else:
        continue

Submission status: Accepted

Solution code:
n = int(input())

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