Problem:


Score : 300 points

Problem Statement

You are given an integer N.

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

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

Constraints

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

Inputs

Input is given from Standard Input in the following format:

N

Outputs

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

h n w

Sample Input 1

2

Sample Output 1

1 2 2

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

Sample Input 2

3485

Sample Output 2

872 1012974 1539173474040

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

Sample Input 3

4664

Sample Output 3

3498 3498 3498



Sample input:
2


Sample output:
1 2 2

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
for i in range(3500):
    h = i + 1
    int_list = [j+ 1 for j in range(3500)]
    app_list = [(h, n, int((N * h * n) / (4 * h * n - N * (h + n))+ 0.1)) for n in int_list
                if 4 * h * n - N * (h + n) > 0 and (N * h * n) % (4 * h * n - N * (h + n)) == 0]
    if len(app_list) > 0:
        app = [str(a) for a in app_list[0]]
        print(" ".join(app))

Submission status: Time Limit Exceeded

Solution code:
n = int(input()) 
for a in range(1,3501):
  for b in range(1,3501):
    c = n*a*b
    d = 4*a*b - n*(a+b)
    if len(str(c))-len(str(d))<4 and c!=0 and d!=0 and c%d==0 and c//d>0:
      print(a,b,c//d)
      exit()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
for h in range(1, 3501):
    for n in range(1, 3501):
        waru = 4 * h * n - N * n - N * h
        if waru != 0:
            w = (N * h * n) / waru
            if w > 0 and int(w) / w == 1:
                print("{} {} {}".format(h, n, int(w)))
                exit()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
 
for h in range(1,3500):
  for n in range(1,3500):
    div=(4*h*n)-(N*n)-(N*h)
    #divが負数ならwは負数になる
    if div>0:
      w=N*h*n/div
      if w.is_integer():
        print(h,n,int(w))
        exit()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N=int(input())

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

Solution code:
N = int(input())

isok=False
for h in range(1,3501):
    for n in range(1,3501):
        bunsi = 4*h*n - N*(h+n)
        bunbo = N*h*n
        if bunsi>0 and bunbo%bunsi==0:
            w = bunbo//bunsi
            isok = True
            break
    if isok:break
        
if isok:
    print(h,n,w)
else:
    print("ここ来たらマジでヤバいが")

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
import math
import itertools

N=int(input())
if(N%4==0):
    x=3*N//4
    print(x,x,x)
    exit()
for x in range(3501):
    if(4*x-2*N>0 and (N*x)%(4*x-2*N)==0):
        h=(N*x)//(4*x-2*N)
        print(h,x,x)
        exit()
for h,n in itertools.product(range(1,3501)[::-1],range(1,3501)[::-1]):
    x=N*h*n
    y=4*n*h-N*n-N*h
    if(y>0 and x%y==0):
        print(h,n,x//y)
        break
"""
4/N=1/h+1/n+1/w
4/N=(nw+hw+hn)/nhw
4nhw/N=nw+hw+hn
4nhw=Nnw+Nhw+Nhn
(4nh-Nn-Nh)w=Nhn
w=Nhn/(4nh-Nn-Nh)

4/N=3/x
4x/N=3
4x=3N
h,n,w=3N/4  (N%4==0)

4/N=1/h+2/x
4/N-2/x=1/h
(4x-2N)/Nx=1/h
h=Nx/(4x-2N)
"""

Submission status: Time Limit Exceeded

Solution code:
import sys
import math
import itertools

N=int(input())
if(N%4==0):
    x=3*N//4
    print(x,x,x)
    exit()
for x in range(3501):
    if(4*x-2*N>0 and (N*x)%(4*x-2*N)==0):
        h=(N*x)//(4*x-2*N)
        print(h,x,x)
        exit()
for h,n in itertools.product(range(1,3501),range(1,3501)):
    x=N*h*n
    y=4*n*h-N*n-N*h
    if(y>0 and x%y==0):
        print(h,n,x//y)
        break
"""
4/N=1/h+1/n+1/w
4/N=(nw+hw+hn)/nhw
4nhw/N=nw+hw+hn
4nhw=Nnw+Nhw+Nhn
(4nh-Nn-Nh)w=Nhn
w=Nhn/(4nh-Nn-Nh)

4/N=3/x
4x/N=3
4x=3N
h,n,w=3N/4  (N%4==0)

4/N=1/h+2/x
4/N-2/x=1/h
(4x-2N)/Nx=1/h
h=Nx/(4x-2N)
"""

Submission status: Time Limit Exceeded

Solution code:
import sys
import math
import itertools

N=int(input())
if(N%4==0):
    x=3*N//4
    print(x,x,x)
    exit()
for x in range(3501):
    if(4*x-2*N>0 and (N*x)%(4*x-2*N)==0):
        h=(N*x)//(4*x-2*N)
        print(h,x,x)
        exit()
for h,n in itertools.product(range(1,3501),range(1,3501)):
    x=N*h*n
    y=4*n*h-N*n-N*h
    if(y>0 and x%y==0):
        print(h,n,x//y)
        break
"""
4/N=1/h+1/n+1/w
4/N=(nw+hw+hn)/nhw
4nhw/N=nw+hw+hn
4nhw=Nnw+Nhw+Nhn
(4nh-Nn-Nh)w=Nhn
w=Nhn/(4nh-Nn-Nh)

4/N=3/x
4x/N=3
4x=3N
h,n,w=3N/4  (N%4==0)

4/N=1/h+2/x
4/N-2/x=1/h
(4x-2N)/Nx=1/h
h=Nx/(4x-2N)
"""

Submission status: Time Limit Exceeded

Solution code:
import sys
import math
import itertools

N=int(input())
if(N%4==0):
    x=3*N//4
    print(x,x,x)
    exit()
for h,n in itertools.product(range(1,3501),range(1,3501)):
    x=N*h*n
    y=4*n*h-N*n-N*h
    if(y>0 and x%y==0):
        print(h,n,x//y)
        break
"""
4/N=1/h+1/n+1/w
4/N=(nw+hw+hn)/nhw
4nhw/N=nw+hw+hn
4nhw=Nnw+Nhw+Nhn
(4nh-Nn-Nh)w=Nhn
w=Nhn/(4nh-Nn-Nh)

4/N=3/x
4x/N=3
4x=3N
h,n,w=3N/4  (N%4==0)

4/N=1/h+2/x
"""

Submission status: Time Limit Exceeded

Solution code:
import sys
import math
import itertools

N=int(input())
for h,n in itertools.product(range(1,3501),range(1,3501)):
    x=N*h*n
    y=4*n*h-N*n-N*h
    if(y>0 and x%y==0):
        print(h,n,x//y)
        break

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
flag = False
for i in range(1,3501):
	for j in range(1,3501):
		if (4*i*j - n*(i+j)) == 0:
			continue
		if (n*i*j)%(4*i*j - n*(i+j)) == 0 and (n*i*j)//(4*i*j - n*(i+j)) > 0:
			print("{} {} {}".format(i,j,(n*i*j)//(4*i*j - n*(i+j))))
			flag = True
			break
	if flag:
		break

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

if N%2 == 0:
    h, n, w = int(N/2), N, N
else:
    flag = 0
    for h in range(1, 3501):
        for n in range(1, 3501):
            for w in range(1, 3501):
                a = int(N*(n*w + h*w + h*n))
                b = int(4 * h * n * w)
                if a == b:
                    flag = 1
                    break
            if flag == 1:
                break
        if flag == 1:
            break
print(h, n, w)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding:utf-8 -*-
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 = (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(str(h)+' '+str(n)+' '+str(w))
                sys.exit()
            else:
                pass
        else:
            pass

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin

gets = stdin.readline


def main():
    n = int(gets())
    h, w = 3500, 0
    flag = False
    for _ in range(3500):
        h -= 1
        w = h
        for _ in range(h):
            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
            w -= 1
        if flag:
            break
    return


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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
            x = (n * h * w)
            y = (4 * h * w - n * h - n * w)
            if x >= y > 0 == x % y:
                print(h, w, x // y)
                flag = True
                break
        if flag:
            break
    return


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin

gets = stdin.readline


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


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
from fractions import *
q=int(input())
n=Fraction(4,q)
for i in range(1,100000000):
	p=n-Fraction(1,i)-Fraction(1,q)
	if(p.numerator==1):
		print(i,q,p.denominator)
		break
	if q%2==0:
		p=n-Fraction(1,i)-Fraction(1,q//2)
		if(p.numerator==1):
			print(i,q//2,p.denominator)
			break

Submission status: Time Limit Exceeded

Solution code:
from fractions import *
q=int(input())
n=Fraction(4,q)
ok=0
for i in range(1,100000000):
	p=n-Fraction(1,i)-Fraction(1,q)
	if ok:break
	if(p.numerator==1):
		print(i,q,p.denominator)
		ok=1

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())                                                                                                               
mx = 3501                                                                                                                      
                                                                                                                               
def func():                                                                                                                    
    for x in range(1, mx):                                                                                                     
        for y in range(x, mx):                                                                                                 
            if (4*x*y-x*N-y*N) == 0:                                                                                           
                y += 1                                                                                                         
            w = (x*y*N) / (4*x*y-x*N-y*N)                                                                                      
            if w > 0 and int(w) == w:                                                                                          
                return x, y, int(w)                                                                                            
A, B, C = func()                                                                                                               
print(A, B, C)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())

import sys

for h in range(1,3501):
    for n in range(h,3501):
        a=(h*n*N)
        b=(4*h*n-(n+h)*N)
        if b==0:
            continue

        w=a/b
        #w=int(w)

        #if w<h:
        #    break

        #print(n,w)
        if a%b==0:
            if N*(n*w+h*w+h*n)!=4*n*w*h:
                continue
            #print(w)
            if w>0:
                w=int(w)
                print(h,n,w)
                '''

                print(4/N)
                print(1/h+1/n+1/w)
                print(a,b)
                print(a/b)
                '''
                sys.exit()

Submission status: Time Limit Exceeded

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
        # print("N1, N2 = ", N1, N2)
        for b in range(1, 3501):
            N3 = b * N1 - N2
            N4 = b * N2
            g = gcd(N3, N4)
            N3 //= g
            N4 //= g
            if N3 == 1:
                print(a, b, N4)
                return

# for N in range(2, 100):
#     # print("N:::", N)
#     solve(N)
    
solve(N)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())

import sys

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

        w=a/b
        #w=int(w)

        #if w<h:
        #    break

        #print(n,w)
        if a%b==0:
            if N*(n*w+h*w+h*n)!=4*n*w*h:
                continue
            #print(w)
            if w>0:
                w=int(w)
                print(h,n,w)
                '''

                print(4/N)
                print(1/h+1/n+1/w)
                print(a,b)
                print(a/b)
                '''
                sys.exit()

Submission status: Time Limit Exceeded

Solution code:
import sys
N=int(input())
if N%2==0:
  print(N//2,N,N)
else:
  for i in range(1,3501):
    for j in range(1,i):
      for k in range(1,j):
        if 4*i*j*k==N*(i*j+ j*k+k*i):
          print(i,j,k)
          sys.exit()

Submission status: Time Limit Exceeded

Solution code:

import fractions as fr
from itertools import count

N = int(input())

for a in count(1):
  if (a*N)%(3*a-1) == 0:
    h = N
    n = a*N
    w = (a*N)//(3*a-1)
    print(h,n,w)
    break

Submission status: Time Limit Exceeded

Solution code:
import sys
N=int(input())
if N%2==0:
  print(N//2,N,N)
else:
  for i in range(1,10**5):
    for j in range(i+1):
      if 3*i*j==N*(i+j):
        print(N,i,j)
        sys.exit()

Submission status: Time Limit Exceeded

Solution code:
import sys
import socket

if socket.gethostname() == 'N551J':
    sys.stdin = open('c1.in')


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


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


def read_str_list():
    return input().split()


def read_str():
    return input()


def solve():
    n = read_int()
    for a in range(1, 3501):
        for b in range(1, 3501):
            d = 4 * a * b - n * b - n * a
            if d != 0:
                if (n * a * b) % d == 0:
                    c = n * a * b // d
                    if c > 0:
                        return a, b, c
    return 0


def main():
    res = solve()
    print(*res)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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):
            w = (4 * h * n - N * h - N * n) / (N * h * n)
            if w > 0 and int(w) == w:
                ans = [h, n, w]
                flag = True
                break
        if flag:
            break
    ans = " ".join(map(str, map(int, ans)))
    return ans


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


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:

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

Solution code:
# https://atcoder.jp/contests/tenka1-2017/tasks/tenka1_2017_c

N = int(input())

hn = []
for i in range(1, 3500 + 1):
    for j in range(1, 3500 + 1):
        hn.append((i, j))
for h, n in hn:
    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)
        print(h, n, w)
        break

Submission status: Memory Limit Exceeded

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

import numpy as np

N = int(input())

"""
4xyz = N(xy+xz+yz)
(4xy-Nx-Ny)z = Nxy
"""

U = 3500
x = np.arange(U+1,dtype=np.int64).reshape(U+1,1)
y = np.arange(U+1,dtype=np.int64).reshape(1,U+1)

den = 4*x*y - N*x - N*y
num = N*x*y

x,y = np.where((num % den == 0) & (num != 0) & (den > 0))
x,y = x[0],y[0]

z = (N*x*y) // (4*x*y - N*x - N*y)
print(x,y,z)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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):
            if 4 * a * b - n * b - n * a == 0:
                continue
            c = (n * a * b) // (4 * a * b - n * b - n * a)
            if c < 1:
                continue
            if 4 * a * b * c == n * (a * b + b * c + c * a):
                print(a, b, c)
                return
    return


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())

ans = None
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 w > 0 and w.is_integer() and 4/N == 1/h + 1/n + 1/w:
        ans = [h, n, int(w)]
        break
  if ans:
    break
print(" ".join(map(str, ans)))

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
N = int(input())
for m in range(int(N/4+1), 3501):
  for n in range(m, 3501):
    if 4 * m * n - N * n - N * m == 0:
      h = -10**10
    else:
      h = m * N * n / (4 * m * n - N * n - N * m)
    if h == int(h) and 0 <= h <= 3500:
      print(int(h),m,n)
      exit()

Submission status: Accepted

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

# In[14]:


N = int(input())


# In[15]:


for h in range(1,3500+1):
    for n in range(h,3500+1):
        tmp = 4*h*n - N*n - N*h
        if tmp > 0 and (N*h*n)%tmp == 0:
            w = (N*h*n)//tmp
            print(h,n,w)
            break
    else:
        continue
    break


# In[ ]:

Submission status: Accepted

Solution code:
N = int(input())
A,B,C = 0,0,0
for TA in range(1,3501):
    for TB in range(1,3501):
        Numer = TA*TB*N
        Denom = 4*TA*TB-(TA+TB)*N
        if Denom>0 and Numer>0 and Numer%Denom==0:
            A = TA
            B = TB
            C = Numer//Denom
print('{} {} {}'.format(A,B,C))

Submission status: Accepted

Solution code:
n=int(input())
for i in range(3500):
    for j in range(3500):
        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)))
            exit()

Submission status: Accepted

Solution code:
N = int(input())
for h in range(1,3500):
    for n in range(1,3500):
        flg = False
        try:
            w = (N*h*n)/(4*h*n-N*n-N*h)
            if w >= 0 and w.is_integer():
                flg = True
        except:
            pass
        if flg:
            print(h,n,int(w))
            exit(0)

Submission status: Accepted

Solution code:
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq

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

Submission status: Accepted

Solution code:
N=int(input())
ans=next([x,y,N*x*y//(4*x*y-N*(x+y))]for x in range(1,3501)for y in range(1,3501)if 4*x*y>N*(x+y) and (N*x*y)%(4*x*y-N*(x+y))==0)
print(*ans)

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


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

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

    return


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
from sys import exit
from collections import deque
from copy import deepcopy
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod=MOD):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x,mode='counter'):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    if mode=='counter':
        return C
    S = set([1])
    for k in C:
        T = deepcopy(S)
        for x in T:
            for i in range(1,C[k]+1):
                S.add(x*(k**i))
    if mode=='set':
        return S
    if mode=='list':
        return sorted(list(S))

######################################################

N=intput()
for h,n in product(range(1,3501),repeat=2):
    if 4*h*n-N*(h+n)==0:
        continue
    w=N*h*n//(4*h*n-N*(h+n))
    if 0<w<=3500 and (4*h*n-N*(h+n))*w==N*h*n:
        print(h,n,w)
        exit()

Submission status: Accepted

Solution code:
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit

INF = 1 << 50
EPS = 1e-8
mod = 10 ** 9 + 7


def run():
    N = int(input())
    for h in range(1, 3501):
        if 4 * h - N <= 0:
            continue
        s = math.ceil(N * h / (4 * h - N))
        for n in range(s, 3501):
            v = N * h * n
            a = 4 * h * n - N * n - N * h
            if a <= 0:continue
            if not v % a:
                w = v // a
                print(f'{h} {n} {w}')
                return

if __name__ == "__main__":
    run()

Submission status: Accepted

Solution code:
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit

INF = 1 << 50
EPS = 1e-8
mod = 10 ** 9 + 7


def run():
    N = int(input())
    for h in range(1, 3501):
        for n in range(1, 3501):
            v = N * h * n
            a = 4 * h * n - N * n - N * h
            if a <= 0:continue
            if not v % a:
                w = v // a
                print(f'{h} {n} {w}')
                return

if __name__ == "__main__":
    run()

Submission status: Accepted

Solution code:
import math
n=int(input())
def s_bunkai(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
if n%2==0:
    print(n,n,n//2)
else:
    num=s_bunkai(n)
    num2=num[0][0]
    if (num2+1)%4==0:
        num3=(num2*2+2)//4
        num4=n*num3
        print(num4//2,num4//num2,num4//num2)
    else:
        yn=0
        for i in range(len(num)):
            if num[i][0]%4==3:
                num2=num[i][0]
                yn=1
                break
        if yn==1:
            num3=(num2*2+2)//4
            num4=n*num3
            print(num4//2,num4//num2,num4//num2)
        else:
            yn=0
            for i in range(n//4,3501):
                for j in range(i,3501):
                    num5=(i*j)//math.gcd(i,j)
                    if num5%n==0:
                        num6=(num5//n)*4
                        num7=num6-(num5//i)-(num5//j)
                        if num5%num7==0 and num7>0:
                            print(i,j,num5//num7)
                            yn=1
                            break
                if yn==1:
                    break

Submission status: Accepted

Solution code:
N = int(input())

L = 3500 + 1

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

Submission status: Accepted

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

import sys

N = int(input())

for h in range(1, 3501):
    for n in range(1, 3501):
        divisor = (4*h*n - N*h - N*n)
        if divisor <= 0:
            continue
        if (N*h*n) % divisor == 0:
            m = (N * h * n) // divisor
            print(h, n, m)
            sys.exit(0)

Submission status: Accepted

Solution code:
N=int(input())

for h in range(1,3501):
    for n in range(1,3501):
        if 4*n*h>N*(h+n) and N*n*h%(4*n*h-N*(h+n))==0:
            w=N*n*h//(4*n*h-N*(h+n))
            print('{} {} {}'.format(h,n,w))
            exit(0)

Submission status: Accepted

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(100):
        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: Accepted

Solution code:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from numba import njit

def main():
    N = int(input())
    @njit
    def solve(N):
        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 and not (shisu / bosu) % 1:
                    return h, n , int((h * N * n) / (n * (h * 4 - N) - h * N))
    r = solve(N)
    print(*r , sep=' ')

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from numba import njit

def main():
    N = int(input())
    @njit
    def solve(N):
        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:
                        return h, n , int((h * N * n) / (n * (h * 4 - N) - h * N))
    r = solve(N)
    print(*r , sep=' ')

if __name__ == '__main__':
    main()