Problem:


Score : 300 points

Problem Statement

You are given an integer N.

Find a triple of positive integers h, n and w such that 4/N = 1/h + 1/n + 1/w.

If there are multiple solutions, any of them will be accepted.

Constraints

It is guaranteed that, for the given integer N, there exists a solution such that h,n,w \leq 3500.

Inputs

Input is given from Standard Input in the following format:

N

Outputs

Print a triple of positive integers h, n and w that satisfies the condition, in the following format:

h n w

Sample Input 1

2

Sample Output 1

1 2 2

4/2 = 1/1 + 1/2 + 1/2.

Sample Input 2

3485

Sample Output 2

872 1012974 1539173474040

It is allowed to use an integer exceeding 3500 in a solution.

Sample Input 3

4664

Sample Output 3

3498 3498 3498



Sample input:
2


Sample output:
1 2 2

Submission status: Accepted

Solution code:
N = int(input())
for h in range(1, 3500 + 1):
        for n in range(h, 3500 + 1):
                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)
                        print("{} {} {}".format(h, n, w))
                        exit()

Submission status: Accepted

Solution code:
N = int(input())
for h in range(1, 3500 + 1):
        for n in range(h, 3500 + 1):
                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)
                        print("{} {} {}".format(h, n, w))
                        exit()

Submission status: Accepted

Solution code:
from sys import stdin

gets = stdin.readline

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from sys import stdin

gets = stdin.readline


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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())
ans = None
for i in range(1, 3501, 1):
	for j in range(1, 3501, 1):
		dominator = 4 * i * j - n * (i + j)
		if dominator > 0:
			numerator = i * j * n
			if numerator % dominator == 0:
				ans = (i, j, int(numerator / dominator))
				break
	if ans is not None:
		break
print(" ".join(map(str, ans)))

Submission status: Accepted

Solution code:
from itertools import product

def inpl(): return tuple(map(int, input().split()))

N = int(input())

for b, c in product(range(max(1, N//4), 3500), range(max(1, N//4), 3500)):
    top = N*b*c
    bottom = 4*b*c - N*c -N*b

    if bottom > 0 and (top%bottom == 0):
        a = top // bottom
        print(a, b, c)
        break

Submission status: Accepted

Solution code:
N = int(input())

for h in range(1, 3501):
    a = 4 * h - N
    if a <= 0:
        continue
    b = N * h
    for n in range(max(h, b // a + 1), 3501):
        q = 4 * h * n - N * h - N * n
        if q <= 0:
            continue
        p = N * h * n
        if p % q == 0:
            w = int(p / q)
            print(str(h) + ' ' + str(n) + ' ' + str(w))
            exit()

Submission status: Accepted

Solution code:
N = int(input())

for h in range(1, 3501):
    for n in range(h, 3501):
        q = 4 * h * n - N * h - N * n
        if q <= 0:
            continue
        p = N * h * n
        if p % q == 0:
            w = int(p / q)
            print(str(h) + ' ' + str(n) + ' ' + str(w))
            exit()

Submission status: Accepted

Solution code:
N = int(input())

for h in range(1, 3501):
    for n in range(h, 3501):
        q = 4 * h * n - N * h - N * n
        if q <= 0:
            continue
        p = N * h * n
        if p >= q and p % q == 0:
            w = int(p / q)
            print(str(h) + ' ' + str(n) + ' ' + str(w))
            exit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    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:
                w = (N * h * n) // (4 * h * n - N * (n + h))
                print(str(h) + " " + str(n) + " " + str(w))
                exit()

Submission status: Accepted

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

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

N = int(input())

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

def solve(N):
    for a in range(1, 3501):
        N1 = 4*a - N
        N2 = N * a
        if N1 < 0: continue
        for b in range(1, 3501):
            N3 = b * N1 - N2
            N4 = b * N2
            if N4 > 0 and N3 > 0 and N4 % N3 == 0:
                print(a, b, N4//N3)
                return
    
solve(N)

Submission status: Accepted

Solution code:
import math

originN = int(raw_input())

isValid = False
for h in xrange(1, 3501):
    for n in xrange(1, 3501):
        if (4*n*h-n*originN-h*originN) > 0 and (originN*n*h) % (4*n*h-n*originN-h*originN) == 0:
            isValid = True
            print str(h)+" "+str(n)+" "+str((originN*n*h)/(4*n*h-n*originN-h*originN))
            break
    if isValid: break

Submission status: Accepted

Solution code:
import math

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

Submission status: Accepted

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


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


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

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


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

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

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

Submission status: Accepted

Solution code:
def solve(n):
    if n & 1 == 0:
        return n, n, n // 2
    for h in range(n // 4, 3501):
        nh = n * h
        for w in range(h, 3501):
            nm = 4 * h * w - nh - n * w
            if nm <= 0:
                continue

            dnm = nh * w
            if dnm % nm == 0:
                return h, w, dnm // nm


n = int(input())
print(*solve(n))

Submission status: Accepted

Solution code:
import sys
from math import *

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]

    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 N * (n *w  + h * w + n * h) == 4 * h * n * w:
                    print h, n, w
                    return


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from fractions import Fraction
from math import ceil


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

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

    if r == 0:
        print(h, n, w)
        break

Submission status: Accepted

Solution code:

import fractions as fr
from itertools import count,product
from math import ceil

N = int(input())

if N%2 == 0:
  print(N,N,N//2)
  exit()

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

Submission status: Accepted

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

    for h in range(1, 3501):
        for n in range(1, 3501):
            r1 = h * n * N
            r2 = 4 * h * n - h * N - n * N
            if r2 > 0 and r1 % r2 == 0:
                print "%d %d %d" % (h, n, r1 / r2)
                return

main()

Submission status: Accepted

Solution code:
# coding: utf-8

import math
import fractions
import heapq
import collections
import re
import array
import bisect

from collections import Counter, defaultdict


def array2d(dim1, dim2, init=None):
    return [[init for _ in range(dim2)] for _ in range(dim1)]


def main():
    N = int(input())
    for i in range(1, 3501):
        for j in range(1, i + 1):
            fb = 4 * i * j - N * (i + j)
            if fb <= 0:
                continue
            fa = N * i * j
            k = int(fa / fb)
            if (k * fb == fa):
                print("{} {} {}".format(i, j, k))
                return


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# coding: utf-8
def II(): return int(input())
def ILI(): return list(map(int, input().split()))


def read():
    N = II()
    return (N,)


def solve(N):
    ans = []
    for h in range(1, 3501):
        flag = False
        for n in range(1, 3501):
            if 4 * h * n - N * h - N * n == 0:
                continue
            div, mod = divmod(N * h * n, 4 * h * n - N * h - N * n)
            if mod == 0 and div > 0:
                ans = [h, n, div]
                flag = True
                break
        if flag:
            break
    ans = " ".join(map(str, ans))
    return ans


def main():
    params = read()
    print(solve(*params))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env pypy3

import itertools


MAX_ANS = 3500


def solve(n):
    for h, m in itertools.product(range(1, MAX_ANS + 1), repeat=2):
        d = 4 * h * m - n * m - n * h
        if d <= 0:
            continue
        w, mo = divmod(n * h * m, d)
        if mo == 0 and w > 0:
            return h, m, w
    assert False


def main():
    n = int(input())
    res = solve(n)
    print(*res)


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

Submission status: Accepted

Solution code:
n = int(input())
c = 0
for a in range(1, 3501):
    for b in range(a, 3501):
        if 4*a*b - n*(a+b) > 0 and n*a*b % (4*a*b - n*(a+b)) == 0:
            c = n*a*b // (4*a*b - n*(a+b))
            print('{} {} {}'.format(a, b, c))
            break
    if c:
        break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

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

def pf(s):
    print(s, flush=True)

def main():
    n = I()
    if n%2 == 0:
        return "{} {} {}".format(n,n,n//2)
    t = 4/n
    for i in range(1,3501):
        c = t - 1/i
        for j in range(i,3501):
            d = c - 1/j
            if d <= 0:
                continue
            e = 1 / d
            if e > 3501:
                continue
            f = math.ceil(e)
            if f > 0 and abs(d - 1/f) < eps:
                return '{} {} {}'.format(i,j,f)
            f = math.floor(e)
            if f > 0 and abs(d - 1/f) < eps:
                return '{} {} {}'.format(i,j,f)

    return -1



print(main())

Submission status: Accepted

Solution code:
N = int(input())

def calc(h, n):
    a = N*h*n
    b = 4*h*n - N*n - N*h
    if b != 0:
        if a % b == 0 and a // b <= 3500 and a // b >= 1:
            return a // b
        else:
            return -1
    else:
        return -1

ans = 0
for h in range(1, 3501):
    for n in range(h, 3501):
        w = calc(h, n)
        if w > 0:
            ans = (h, n, w)
            break
print(ans[0],ans[1], ans[2])

Submission status: Accepted

Solution code:
N = int(input())
ans = []
for h in range(1, 3501):
    for n in range(h, 3501):
        x = 4 * h * n - N * n - N * h
        if x == 0:
            continue
        w = N * h * n // x
        if 4 * h * n * w == N * (n * w + h * w + h * n):
            ans = [h, n, w]
            break
print(' '.join(map(str, ans)))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Runtime Error

Solution code:
import sys
# sys.setrecursionlimit(100000)


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


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    n = input_int()
    for a in range(1, 3501):
        for b in range(1, 3501):
            numerator = a * b * n
            denominator = 4 * a * b - a * n - b * n
            if denominator == 0:
                continue
            c = numerator // denominator
            if n / 4 == 1 / a + 1 / b + 1 / c:
                print(a, b, c)
                return
    return


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
N=input()
A=N//4+1

Submission status: Runtime Error

Solution code:
# (A,B,C)<=3500
# 4/N = (1/A)+(1/B)+(1/C)
# (4/N)-(1/A) = (1/B)+(1/C)
# (4A-N)/AN   = (B+C)/BC

# XX-(4A-N)X+AN=0
# X = (-b±sqrt(bb-4c))/2 (a=1)
#   = ((4A-N)±sqrt((4A-N)(4A-N)-4AN))/2
#   = ((4A-N)±sqrt(16AA-12AN+NN))/2


def BiSearch(Func,N):
    Left  = 0
    FLeft = Func(Left)
    Right  = N
    FRight = Func(Right)
    Flag = False
    while Left<=Right:
        Med  = (Left+Right)//2
        FMed = Func(Med)
        if FMed==N:
            Flag = True
            return Med
        elif FMed>N:
            Right  = Med-1
            FRight = Func(Right)
        else:
            Left  = Med+1
            FLeft = Func(Left)
    if not Flag:
        return False
def SquareRootSearch(K):
    return BiSearch(lambda N:N*N,K)

N = int(input())
for TA in range(1,3501):
    SqrtX = SquareRootSearch(16*(TA**2)-(12*TA*N)+(N**2))
    if SqrtX:
        NumerB = (4*TA-N)+SqrtX
        NumerC = (4*TA-N)-SqrtX
        if NumerB%2==0 and NumerC%2==0 and NumerB>0 and NumerC>0:
            A = TA
            B = NumerB//2
            C = NumerC//2
print('{} {} {}'.format(A,B,C))

Submission status: Runtime Error

Solution code:
N = int(input())

if N % 2 == 0:
  print(N//2, N, N)
else:
  for i in range(1, N):
    if N < 4*i:
      n = 4*i - N
      break
  if n == 1:
    j, k = 2*N*i, 2*N*i
  else:
    if i % 3 == 0:
      j, k = 2*N*i//3, 2*N*i//3
    else:
      for x in range(10):
        flag = False
        for y in range(1, n//2+1):
          if ((N*i)%y==0) and ((N*i)%(n-y)==0):
            j = (N*i) // y
            k = (N*i) // (n-y)
            flag = True
            break
        if flag:
          break
        else:
          i += 1
          n += 4
  print(i, j, k)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N=int(input())

for h in range(1,3500+1):
    for n in range(1,3500+1):
        if  (N*h*n)%(4*h*n-N*(h+n))==0:
            try:
                H,N,W=h,n,(N*h*n)//(4*h*n-N*(h+n))
            except:
                pass
print(H,N,W)

Submission status: Runtime Error

Solution code:
N = int(input())
if N%2==0:
    a=N//2
    b=N
    c=N
    print(a,b,c)
else:
    for ai in range(N//4,3500):
        for bi in range(N//4,3500):
            ci = N*ai*bi/(4*ai*bi-N*ai-N*bi)
            if ci == int(ci) and ci > 0:
                print(ai,bi,int(ci))
                exit()

Submission status: Runtime Error

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*h*n*w/(h*n+n*w+h*w) = N
    n*w+h*w = (n+h)*w = k*h*n  => k = (n+h)*w/(h*n)

    4hnw/(k+1)hn=4w/(k+1) = N
    """
    N = read_int()
    for w in range(1, 3501):
        if (4*w)%N == 0:
            k = (4*w)//N-1
            for n in range(1, 3501):
                if k*n-w > 0 and (n*w)%(k*n-w) == 0:
                    h = n*w//(k*n-w)
                    return h, n, w



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

Submission status: Runtime Error

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*h*n*w/(h*n+n*w+h*w) = N
    n*w+h*w = (n+h)*w = k*h*n  => k = (n+h)*w/(h*n)

    4hnw/(k+1)hn=4w/(k+1) = N
    """
    N = read_int()
    for w in range(1, 3501):
        if (4*w)%N == 0:
            k = (4*w)//N-1
            for n in range(1, 3501):
                if k*n-w > 0 and (n*w)%(k*n-w) == 0:
                    h = n*w//(k*n-w)
                    if h > 0:
                        return h, n, w


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

Submission status: Runtime Error

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*h*n*w/(h*n+n*w+h*w) = N
    n*w+h*w = (n+h)*w = k*h*n  => k = (n+h)*w/(h*n)

    4hnw/(k+1)hn=4w/(k+1) = N
    """
    N = read_int()
    for w in range(1, 3501):
        if (4*w)%N == 0:
            k = (4*w)//N-1
            for n in range(1, 3501):
                if k*n-w != 0 and (n*w)%(k*n-w) == 0:
                    h = n*w//(k*n-w)
                    if h > 0:
                        return h, n, w


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

Submission status: Runtime Error

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*h*n*w/(h*n+n*w+h*w) = N
    n*w+h*w = (n+h)*w = k*h*n  => k = (n+h)*w/(h*n)

    4hnw/(k+1)hn=4w/(k+1) = N
    """
    N = read_int()
    for w in range(1, 3501):
        if (4*w)%N == 0:
            k = (4*w)//N-1
            for n in range(1, 3501):
                if k*n-w != 0 and (n*w)%(k*n-w) == 0:
                    h = n*w//(k*n-w)
                    if h > 0:
                        print(f'{N}=4*{h}*{n}*{w}/({h}*{n}+{n}*{w}+{h}*{w})')
                        return h, n, w


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

Submission status: Runtime Error

Solution code:

n = int(input())
if n %2 == 0:
  ans1 = str(n)
  ans2 = str(n//2)
  print(ans1 + " " + ans1 + " " + ans2)
  quit()
if n % 3 == 0:
  ans1 = str(n*2)
  ans2 = str(n//3)
  print(ans1 + " " + ans1 + " " + ans2)
  quit()
  
for i in range(1, 3501):
  for j in range(1, 3501):
      k = int(1/(4/n-1/i-1/j))
      if k>0 and 4/n==1/i+1/j+1/k:
        print(str(i)+" "+str(j)+" "+str(k))
        quit() 
for i in range(1, 876):
  for j in range(1, 876):
      k = int(1/(4/n-1/(4*i)-1/(4*j)))
      if k>0 and 4/n==1/(4*i)+1/(4*j)+1/k:
        print(str(i*4)+" "+str(j*4)+" "+str(k))
        quit()

Submission status: Runtime Error

Solution code:
n = int(input())
if n %2 == 0:
  ans1 = str(n)
  ans2 = str(n//2)
  print(ans1 + " " + ans1 + " " + ans2)
  quit()
for i in range(1, 876):
  for j in range(1, 876):
      k = int(1　/　(4/n　-　1/(4*i)　-　1/(4*j)　))
      if k>0 and 4/n==1/(4*i)+1/(4*j)+1/k:
        print(str(i*4)+" "+str(j*4)+" "+str(k))
        quit()

Submission status: Runtime Error

Solution code:
n = int(input())
"""
if n %2 == 0:
  ans1 = str(n)
  ans2 = str(n//2)
  print(ans1 + " " + ans1 + " " + ans2)
  quit()
"""
for i in range(1, 876):
  for j in range(1, 876):
      k = int(1　/　(4/n　-　1/(4*i)　-　1/(4*j)　))
      if k>0 and 4/n==1/(4*i)+1/(4*j)+1/k:
        print(str(i*4)+" "+str(j*4)+" "+str(k))
        quit()

Submission status: Runtime Error

Solution code:
#include <iostream>

using namespace std;

int main() {
    const int ub = 3500;
    int n; cin >> n;
    for (int x = 1; x <= ub; ++x) {
        for (int y = 1; y <= ub; ++y) {
            int p = n*x*y;
            int q = 4*x*y - n*y - n*x;
            if ((q > 0) && (p % q == 0)) {
                int z = p / q;
                cout << x << " " << y << " " << z << endl;
                return 0;
            }
        }
    }
    return -1;
}

Submission status: Runtime Error

Solution code:
n = int(input())
if n%2==0:
    print(n, n, n//2)
else:
    f = False
    for i in range(1, 3500):
        _h = n/i
        for j in range(1,3500):
            _n = n/j
            w = n/(4-_h-_n)
            if w>0 and w%1==0:
                print(i, j, int(w))
                f = True
            if f: break
        if f: break

Submission status: Runtime Error

Solution code:
n = int(input())

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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*j-n*i
        if t1%t2==0 and 1<=t1//t2<3500:
            print(i,j,t1//t2)
            exit()

Submission status: Runtime Error

Solution code:
N = int(input())
ok = False

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

Submission status: Runtime Error

Solution code:
N = int(input())
b, c, d = 1, 1, 2
while True:
    x = N//4 + b
    y = c*N*x
    tmp = c * (4*x - N) - 1
    if y % tmp == 0:
        z = y // tmp
        break
    else:
        b += 1
print(*[x,y,z], sep=' ')

Submission status: Runtime Error

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

Submission status: Runtime Error

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)
    if w >0 and w.is_integer():
      print(h,n,int(w))
      exit()

Submission status: Runtime Error

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

    for h in range(1, 3501):
        for n in range(h+N-1, 3501):
            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)
                exit()

if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys

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


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


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

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

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


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


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;

int main() {
    int N;
    cin >> N;
    
    for(int n = 1; n <= 3500; n++){
        for(int w = 1; w <= 3500; w++){
            int h_up, h_down;
            h_up = N * n * w;
            h_down = 4 * n * w - N *(n + w);
            
            if(h_down <= 0) continue;
            if(h_up % h_down != 0) continue;
            
            int h;
            h = h_up / h_down;
            
            cout << h << " " << n << " " << w << endl;
            exit(0);
        }
    }
}

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;

int main() {
    int N;
    cin >> N;
    
    for(int n = 1; n <= 3500; n++){
        for(int w = 1; w <= 3500; w++){
            int h_up, h_down;
            h_up = N * n * w;
            h_down = 4 * n * w - N *(n + w);
            
            if(h_down <= 0) continue;
            if(h_up % h_down != 0) continue;
            
            int h;
            h = h_up / h_down;
            
            cout << h << " " << n << " " << w << endl;
            exit(0);
        }
    }
}

Submission status: Runtime Error

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

Submission status: Runtime Error

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