Problem:


Score : 300 points

Problem Statement

You are given an integer N.

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

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

Constraints

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

Inputs

Input is given from Standard Input in the following format:

N

Outputs

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

h n w

Sample Input 1

2

Sample Output 1

1 2 2

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

Sample Input 2

3485

Sample Output 2

872 1012974 1539173474040

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

Sample Input 3

4664

Sample Output 3

3498 3498 3498



Sample input:
2


Sample output:
1 2 2

Submission status: Accepted

Solution code:
n = int(input())

for h in range(1, 3501):
    for w in range(1, 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()

Submission status: Accepted

Solution code:
N=int(input())
'''
4hnw=N(hn+nw+wh)
=(n+w)Nh + nwN
0=(Nw+Nn-4nw)h + nwN
h = -(nwN)/(Nw+Nn-4nw)
'''
for w in range(1,3501):
	for n in range(1,3501):
		if (N*w+N*n!= 4*n*w) :
			h = -(n*w*N)/(N*w+N*n-4*n*w)
			if  h==int(h) and h > 0:
			  print(int(h),n,w)
			  exit(0)

Submission status: Accepted

Solution code:
import math
#import numpy as np
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

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

    return None

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():
    N = in_n()

    for a in range(1, 3500):
        for b in range(a, 3500):
            t1 = N * a * b
            t2 = 4 * a * b - N * (a + b)
            if t2 == 0:
                continue
            else:
                c = t1 / t2
                if c.is_integer() and 1 <= c:
                    print(a, b, int(c))
                    exit()


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():
    N = in_n()

    for a in range(1, 3500):
        for b in range(a, 3500):
            t1 = N * a * b
            t2 = 4 * a * b - N * (a + b)
            if t2 == 0:
                continue
            else:
                c = t1 / t2
                if c.is_integer() and 1 <= c and c <= 3500:
                    print(a, b, int(c))
                    exit()


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a


inf = 10 ** 18
mod = 10 ** 9 + 7

N = ir()
h0 = (3*N)//4
for h in range(h0,3501):
    n0 = (2*N*h)//(4*h-N)
    for n in range(n0,3501):
        if (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:
N = int(input())
for h in range(1,3501):
  for n in range(1,3501):
    a = N*h*n
    b = 4*h*n - N*h - N*n
    if b != 0 and a % b == 0 and 0 < a//b <= 3500:
      print(h,n,a//b)
      exit()

Submission status: Accepted

Solution code:
N = int(input())
for h in range(3501):
    for n in range(3501):
        a = N * h * n
        b = 4 * h * n - N * n - N * h
        if b > 0 and a % b == 0:  # 余りがでない -> 整数
            w = int(a / b)
            print(h, n, w)
            exit()
        else:
            continue

Submission status: Accepted

Solution code:
import math

N = int(input())
f = False
for h in range(1,3501):
    if f:
        break
    for n in range(1,3501):
        if 4*n*h-N*n-N*h == 0:
            continue
        check = N*n*h/(4*n*h-N*n-N*h)
        if check < 0:
          continue
        if check.is_integer():
            print(h, n, math.floor(check))
            f = True
            break

Submission status: Accepted

Solution code:
n = int(input())
if n<=3000:
  for a in range(1,3501):
    for b in range(1,3501):
      s = n*a*b
      #s=4
      t = 4*a*b-n*b-n*a
      #t=8-4-2
      if s<=t*3500:
        if t!=0 and s%t==0 and t>0:
          c = s//t
          print(a,b,c)
          exit()
else:
  for a in range(3501,1,-1):
    for b in range(3501,1,-1):
      s = n*a*b
      #s=4
      t = 4*a*b-n*b-n*a
      #t=8-4-2
      if s<=t*3500:
        if t!=0 and s%t==0 and t>0:
          c = s//t
          print(a,b,c)
          exit()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


N = int(input())
done = False
for h in range(1, 3501):
    for n in range(1, 3501):
        v = (4*h*n) - N*(h+n)
        if v>0 and (N*h*n) % v == 0:
            ans = (h,n, (N*h*n) // v)
            print(" ".join(map(str, ans)))
            done = True
            break
    if done:
        break

Submission status: Accepted

Solution code:
import sys

from numba import njit

input = sys.stdin.readline


@njit("Tuple((i8,i8,i8))(i8)")
def solve(N):
    for h in range(1, 3501):
        for n in range(1, 3501):
            a = N * h * n
            b = 4 * h * n - (h + n) * N
            if b > 0 and a % b == 0:
                w = a // b
                return h, n, w
    return -1, -1, -1


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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
from numba import njit

input = sys.stdin.readline


@njit
def solve(N):
    for h in range(1, 3501):
        for n in range(1, 3501):
            a = N * h * n
            b = 4 * h * n - (h + n) * N
            if b > 0 and a % b == 0:
                w = a // b
                return h, n, w


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


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 = N * h * n
            b = 4 * h * n - (h + n) * 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:
from itertools import product
def main():
    n = int(input())
    for x, y in product(range(1, 3501), repeat = 2):
        if 4 * x * y - n * (x + y) != 0:
            z = n * x * y / (4 * x * y - n * (x + y))
        else:
            continue
        if z.is_integer() and z > 0:
            print(x, y, int(z))
            break

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def solve():
    N = int(input())
    for h in range(1,3500+1):
        for n in range(1,3500+1):
            numerator = N * h * n
            denominator = 4 * h * n - N * n - N * h

            if denominator == 0:
                continue

            w = numerator // denominator
            if numerator % denominator == 0 \
            and 0 < w <= 3500:
                print(h,n,w)
                return
        
if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

N = INT()

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

Submission status: Accepted

Solution code:
from numba import njit


@njit("UniTuple(i8, 3)(i8)")
def solve(N):
    for b in range(1, 3500 + 1):
        for c in range(1, 3500 + 1):
            num = N * b * c
            den = 4 * b * c - N * b - N * c
            if den > 0 and num % den == 0:
                a = num // den
                return a, b, c
    return 0, 0, 0


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

Submission status: Accepted

Solution code:
from numba import njit


@njit
def solve(N):
    for b in range(1, 3500 + 1):
        for c in range(1, 3500 + 1):
            num = N * b * c
            den = 4 * b * c - N * b - N * c
            if den > 0 and num % den == 0:
                return num // den, b, c


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

Submission status: Accepted

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

def main():
    N = int(input())
    for x in range(1,3501):
        for y in range(x,3501):
            bunshi = x*y*N
            bunbo  = 4*x*y-(x+y)*N
            if bunbo>0 and bunshi%bunbo==0:
                print(x,y,bunshi//bunbo)
                exit()

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())

import math

ans = [0,0,0]

for h in range(1,3501):
  for n in range(h,3501):
    if (4*n*h-N*n-N*h) > 0:
      if (N*h*n)%(4*n*h-N*n-N*h) == 0 :
        ans = [h,n,(N*h*n)//(4*n*h-N*n-N*h)]
    if ans[0] != 0:
      break
  if ans[0] !=0:
    break

print(" ".join(map(str,ans)))

Submission status: Accepted

Solution code:
N=int(input())

def isOK(n,w):
    if 4*n*w-N*w-N*n==0:
        return False
    if N*n*w%(4*n*w-N*w-N*n)==0:
        h=N*n*w//(4*n*w-N*w-N*n)
        if 0<h:
            return h
    return False

for i in range(1,3501):
    for j in range(1,3501):
        if isOK(i,j):
            print(i,j,isOK(i,j))
            exit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/tenka1-2017/tasks/tenka1_2017_c
def main():
    N = int(input())

    for h in range(1, 3500 + 1):
        for n in range(1, 3500 + 1):
            if (4 * h * n - N * n - N * h != 0) and (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)
                    return

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from numba import njit

N = int(input())


@njit
def f():
    for h in range(1, 3501):
        for n in range(1, 3501):
            x = 4 * h * n - N * n - N * h
            if x != 0 and N * h * n % x == 0:
                w = N * h * n // x
                if w >= 1:
                    return h, n, w


print(*f())

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())


def solve(h, n):
    if (4*h*n-N*n-N*h) == 0:
        return
    w = N*h*n // (4*h*n-N*n-N*h)
    if w < 1:
        return
    if w*(4*h*n-N*n-N*h) == N*h*n:
        print(h, n, w)
        exit()


if N < 2000:
    for h in range(1, 3501):
        for n in range(1, 3501):
            solve(h, n)
else:
    for h in reversed(range(1, 3501)):
        for n in reversed(range(1, 3501)):
            solve(h, n)

Submission status: Accepted

Solution code:
def tenka17_c():
    N = int(input())
    ans = None
    for x in range(1, 3501):
        for y in range(1, 3501):
            a = N * x * y
            b = 4*x*y - N*y - N*x
            if b < 1: continue
            if a % b == 0:
                ans = (x, y, a//b)
                break
        if ans: break
    print(*ans, sep=' ')

tenka17_c()

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
import numpy as np


n = int(input())
U = 3500
for x in range(1, U+1):
    y = np.arange(1, U+1, dtype=np.int64)
    den = 4 * x * y - n * x - n * y
    num = n * x * y
    y = y[(num % den == 0) & (den > 0)]
    if len(y) > 0:
        y = y[0]
        z = (n * x * y) // (4 * x * y - n * x - n * y)
        break
print(x, y, z)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
import heapq
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')
AtoZ = "abcdefghijklmnopqrstuvwxyz"

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  divisors.sort()
  return divisors

#####MakePrimes######
def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum

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

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############
N = I()

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
import heapq
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')
AtoZ = "abcdefghijklmnopqrstuvwxyz"

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  divisors.sort()
  return divisors

#####MakePrimes######
def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum

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

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############
N = I()

p = factorization(N)[0][0]
r = N//p

k = 1
while True:
  flag = 0
  d = make_divisors(p*k)
  for j in d[1:]:
    if 4*k-1-j in d:
      a = (p*k)//j
      b = (p*k)//(4*k-1-j)
      flag = 1
  if flag:
    break
  k += 1
  
print(a*r,b*r,k*p*r)

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

Submission status: Accepted

Solution code:
def solve(N):
    for h in range(1, 3501):
        for n in range(1, 3501):
            v1 = 4*h*n-N*(h+n)
            v2 = N*h*n
            if v1>0 and v2>0 and v2%v1==0:
                return h, n, v2//v1

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

Submission status: Accepted

Solution code:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7


#############
# Main Code #
#############

N = getN()

def judge(n, h, N1):
    fraction = n * h * N1
    denominator = (4 * h * n) - (N1 * n) - (N1 * h)
    if denominator > 0 and fraction % denominator == 0 and 0 < fraction // denominator <= 3500:
        return fraction // denominator
    return -1

for i in range(1, 3501):
    for j in range(1, 3501):
        res = judge(i, j, N)
        if res > 0:
            print(i, j, res)
            break
    else:
        continue
    break

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


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


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

            if a.is_integer():
                print(int(a),b,c)
                return 0
    return 0
do()

Submission status: Accepted

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

for h in range(1,3501):
    for n in range(1,3501):
        x,y=N*h*n,4*h*n-n*N-h*N
        if y==0:
            continue
        w=x/y
        if w>0 and math.floor(w)==math.ceil(w):
            print(h,n,math.floor(w))
            exit()

Submission status: Accepted

Solution code:
N=int(input())

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

Submission status: Accepted

Solution code:
n=int(input())
a=n*3//4+3
for i in range(max(n//4,1),a):
    for j in range(a-3,3501):
        k=4*i*j-n*(i+j)
        if k==0:
            continue
        x,y=divmod(n*i*j,k)
        if y==0 and x>0:
            print(i,j,x)
            exit()

Submission status: Accepted

Solution code:
n=int(input())
a=n*3//4+3
for i in range(max(n//4,1),a):
    for j in range(a-3,3501):
        k=4*i*j-n*(i+j)
        if k==0:
            continue
        x,y=divmod(n*i*j,4*i*j-n*(i+j))
        if y==0 and x>0:
            print(i,j,x)
            exit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

N=int(input())

for h in range(1,3*N//4+1):
    if 4*h>N:
        for n in range(1,(2*N*h)//(4*h-N)+1):
            if (4*h-N)*n>N*h:
                if (N*h*n)%((4*n*h-N*n-N*h))==0:
                    w=(N*h*n)//((4*n*h-N*n-N*h))
                    print(h,n,w)
                    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*n) > 0 and (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:
import sys
readline = sys.stdin.readline

N = int(readline())

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,(N*i*j)//(4*i*j-N*i-N*j))
            exit()

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

N = int(readline())

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,(N*i*j)//(4*i*j-N*i-N*j))
            exit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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