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:
CONST = 100000

class EndLoop(Exception):
    pass

def solve():
    N = int(input())
    try:
        for h in range(1, CONST):
            for n in range(1, CONST):
                for w in range(1, CONST):
                    if (4 * h * n * w) % (n * w + h * w + h * n):
                        continue

                    if (4 * h * n * w) / (n * w + h * w + h * n) == N:
                        print(h, n, w)
                        raise EndLoop

    except EndLoop:
        pass


solve()

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

for i in range(1, 3501):
    for j in range(i, 3501):
        for k in range(j, 3501):
            if n * (i * j + j * k + k * i) == 4 * i * j * k:
                print(i, j, k)
                exit()

Submission status: Time Limit Exceeded

Solution code:
#! -*- coding:utf-8 -*-
import sys

n = int(input())

if n % 4 == 0:
    print(3*(n//4),3*(n//4),3*(n//4))
elif n % 4 == 2:
    print(2*(n//4)+1,2*(2*(n//4)+1),2*(2*(n//4)+1))
else:
    for i in range(1,3501):
        for j in range(1,i+1):
            for k in range(1,j+1):
                if 4/n == 1/i + 1/j + 1/k:
                    print(i,j,k)
                    sys.exit()

Submission status: Time Limit Exceeded

Solution code:
CONST = 100000

class EndLoop(Exception):
    pass

def solve():
    N = int(input())
    try:
        for h in range(1, CONST):
            for n in range(1, CONST):
                for w in range(1, CONST):
                    if ((4 * h * n * w) / (n * w + h * w + h * n)) == N:
                        print(h, n, w)
                        raise EndLoop
    except EndLoop:
        pass


solve()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
flag = 0
for a in range(1,3501):
    if flag == 1:
        break
    for b in range(1,1751):
        M = (4*a*b - N*a - N*b)
        C = N*a*b
        if M < 0 :
            continue
        elif M != 0:
            if C//M == C/M:
                c = C//M
                print(a,b,c)
                flag = 1
                break

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
flag = 0
for a in range(1,3501):
    if flag == 1:
        break
    for b in range(1,3501):
        M = (4*a*b - N*a - N*b)
        C = N*a*b
        if M < 0 :
            continue
        elif M != 0:
            if C//M == C/M:
                c = C//M
                print(a,b,c)
                flag = 1
                break

Submission status: Time Limit Exceeded

Solution code:
N= 3485
d =[]
import math
for a in range(1, 1+math.floor(N*3/4)):
    if 4*a>N:
        for b in range(1, 1+math.floor((2*a*N)/(4*a-N))):
            x = 4/N
            y = (1/a)+(1/b)
            if x > y:
                c = 1/((4/N)-(1/a)-(1/b))
                if c == int(c):
                    d.append([int(a),int(b),int(c)])

                    
print(d[0])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
lim = 1
for a in range(1, 3501):
    if N <= 4 * a:
        lim = a
        break
ft = False
for i in range(lim, 3501):
    for j in range(lim, 3501):
        if 4 / N >= 1 / i + 1 / j:
            for k in range(lim, 3501):
                if 4 / N >= 1 / i + 1 / j + 1 / k:
                    if 4 * i * j * k == N * (i * j + j * k + k * i):
                        print(str(i) + " " + str(j) + " " + str(k))
                        ft = True
                        break
        if ft == True:
            break
    if ft == True:
        break

Submission status: Time Limit Exceeded

Solution code:
import math

num = int(input())
ans = [0,0,0]
value = 4 / num
limit = [math.ceil(num/4),0.0,0.0]
flag = 0
# print(limit)
if num % 4 == 0:
    a = int(num*3 / 4)
    print(a,a,a)
    flag = 1
for a in range(limit[0],3500):
    if(flag):
        break
    remain = value - 1/a
    if remain <= 0:
        continue
    limit[1] = math.ceil(1/remain)
    if limit[1]>3500:
        continue
    for b in range(limit[1],3500):
        # print(a,b,remain,limit)
        if(flag):
            break
        remain = value - 1/a - 1/b
        if remain <= 0:
            continue
        limit[2] = math.ceil(1/remain)
        if limit[2]>3500:
            continue
        pos_up = limit[2]
        pos_low = limit[2]-1
        if value == 1/a + 1/b + 1/pos_up:
            print(a,b,pos_up)
            flag=1
            break
        if pos_low != 0 and value == 1/a + 1/b + 1/pos_low:
            print(a,b,pos_low)
            flag=1
            break

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=1
b=1
c=1
z=0
while a<=3500:
    b=a
    if z==1:
        break
    while b<=3500:
        if 4*a*b- b*n -a*n !=0:
            c=a*b*n/(4*a*b- b*n -a*n)
            if int(c)==c and c>0:
                print(a, b, int(c)) 
                z=1
                break 
        b+=1
    a+=1

Submission status: Time Limit Exceeded

Solution code:
import math

num = int(input())
ans = [0,0,0]
value = 4 / num
limit = [math.ceil(num/4),0.0,0.0]
flag = 0
# print(limit)
if num % 4 == 0:
    a = int(num*3 / 4)
    print(a,a,a)
    flag = 1
for a in range(limit[0],limit[0]+3500):
    if(flag):
        break
    remain = value - 1/a
    if remain <= 0:
        continue
    limit[1] = math.ceil(1/remain)
    if limit[1]>3500:
        continue
    for b in range(limit[1],limit[1]+3500):
        # print(a,b,remain,limit)
        if(flag):
            break
        remain = value - 1/a - 1/b
        if remain <= 0:
            continue
        limit[2] = math.ceil(1/remain)
        if limit[2]>3500:
            continue
        pos_up = limit[2]
        pos_low = limit[2]-1
        if value == 1/a + 1/b + 1/pos_up:
            print(a,b,pos_up)
            flag=1
            break
        if pos_low != 0 and value == 1/a + 1/b + 1/pos_low:
            print(a,b,pos_low)
            flag=1
            break

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())

flag = 0
for a in range(1,3501):
    if flag: break
    for b in range(a,3501):
        x = 4*a*b - n*a - n*b
        y = n*a*b
        if x>0 and y>x and y%x==0: c=y//x; print(a,b,c); flag = 1; break

Submission status: Time Limit Exceeded

Solution code:
N=input()
c=0
for i in range(3500):
	h=i+1
	for j in range(3500):
		n=i+1
		for k in range(3500):
			w=k+1
			if 4*h*n*w==N*n*w+N*h*w+N*n*h:
				c=1
			if c==1:
				break
		if c==1:
			break
	if c==1:
		break
print str(h)+" "+str(n)+" "+str(w)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

li = [x for x in range(1,3501)]

def cal(h,n,w,N):
    if (h*n + n*w + w*h)*N == 4*h*n*w:
        return True
    else:
        return False

ct = 0
for h in range((3*N//4),len(li)):
    for n in range(h,len(li)):
        for w in range(n,len(li)):
            if cal(h,n,w,N):
                print("{} {} {}".format(h,n,w))
                ct= 1
                break
        if ct:
            break
    if ct:
        break

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8

N = int(raw_input())

for h in range(1, 3501):
    for n in range(1, 3501):
        for w in range(1, 3501):
            if 4 * h * n * w == N * n * w + N * h * w + N * h * n:
                print h, n, w
                exit()

Submission status: Time Limit Exceeded

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

N = int(input())

ans = 4/N

for h in range(1,3500):
	for n in range(h,3500):
		for w in range(n,3500):
			if 1/h + 1/n + 1/w == ans:
				print(str(h) + " " + str(n) + " " + str(w))
				exit(0)

Submission status: Time Limit Exceeded

Solution code:

n = int(input())

val = 4/n
x = 1
ans = []
while True:
  if val >= 1/x:
    val -= 1/x
    ans.append(x)
    continue
  if val <= 0:
    break
  x += 1

if len(ans) == 1:
  ans = [ans[0]*3, ans[0]*3, ans[0]*3]
elif len(ans) == 2:
  ans = [ans[0], ans[1]*2, ans[1]*2]

print('%d %d %d' % tuple(ans) )

Submission status: Memory Limit Exceeded

Solution code:
import numpy as np

N = int(input())
k = 4 / N

def f(h, n):
    hn = h * n
    return -(hn / (n + h - hn * k))


h, n = np.reshape(np.indices((3500, 3500)), (2, 3500 * 3500)) + 1
w = f(h, n)
indices = np.where((w % 1 == 0) & (0 < w))
print(*(np.stack((w, h, n), -1)[indices].astype(int))[0])

Submission status: Accepted

Solution code:
x = int(input())

for ch in range(1, 3501):
    for cn in range(1, 3501):
        a = ch*cn
        if 4*ch*cn % x:
            continue
        b = 4*ch*cn//x - cn - ch
        if b > 0 and a % b == 0:
            print(ch, cn, a//b)
            print()
            exit()

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
import sys
N=int(input())
for n in range(1,2*N+1):
  for w in range(1,N+1):
    try:
      h = w*n*N // (4*w*n-(n+w)*N)
    except:
      continue
    if h>0 and h*(4*w*n-(n+w)*N) - w*n*N == 0:
      print(h,n,w)
      sys.exit()

Submission status: Accepted

Solution code:
import sys
from math import ceil,floor
N=int(input())
b=3501

for h in range(ceil(3*N/4),b):
  for w in range(1,floor(3*N/4)+1):
    if 4*h*w-N*h-N*w>0:
      if N*h*w % (4*h*w-N*h-N*w)==0:
        n=N*h*w//(4*h*w-N*h-N*w)
        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):
    a = (4 * h * n) - N * h - N * n
    if a <= 0:
      continue
    w = (N * h * n) / a
    if w.is_integer() and 0 < w:
      print(h, n, int(w))
      exit(0)

Submission status: Accepted

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

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

Submission status: Accepted

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

import sys
from typing import Any, Callable, Deque, Dict, List, Mapping, Optional, Sequence, Set, Tuple, TypeVar, Union
# import time
# import math, cmath
# import numpy as np
# import scipy.sparse.csgraph as cs            # csgraph_from_dense(ndarray, null_value=inf), bellman_ford(G, return_predecessors=True), dijkstra, floyd_warshall
# import random                                # random, uniform, randint, randrange, shuffle, sample
# import string                                # ascii_lowercase, ascii_uppercase, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from datetime import date, datetime          # date.today(), date(year,month,day) => date obj; datetime.now(), datetime(year,month,day,hour,second,microsecond) => datetime obj; subtraction => timedelta obj
# from datetime.datetime import strptime       # strptime('2019/01/01 10:05:20', '%Y/%m/%d/ %H:%M:%S') returns datetime obj
# from datetime import timedelta               # td.days, td.seconds, td.microseconds, td.total_seconds(). abs function is also available.
# from copy import copy, deepcopy              # use deepcopy to copy multi-dimentional matrix without reference
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import _heapify_max, _heappop_max, _siftdown_max
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from fractions import Fraction               # Fraction(a, b) => a / b ∈ Q. note: Fraction(0.1) do not returns Fraciton(1, 10). Fraction('0.1') returns Fraction(1, 10)



def main():
    Num = Union[int, float]
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79e+308
    # inf = 2 ** 63 - 1             # (for fast JIT compile in PyPy) 9.22e+18
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input():  return sys.stdin.readline().rstrip()
    def ii():     return int(input())
    def isp():    return input().split()
    def mi():     return map(int, input().split())
    def mi_0():   return map(lambda x: int(x)-1, input().split())
    def lmi():    return list(map(int, input().split()))
    def lmi_0():  return list(map(lambda x: int(x)-1, input().split()))
    def li():     return list(input())
    def debug(x): print(x, file=sys.stderr)
    # def _heappush_max(h, item): h.append(item); _siftdown_max(h, 0, len(h)-1)
    
    def calc(N):
        if N % 2 == 0:
            return N, N, N // 2
        else:
            # h = Nnw / (4nw - Nw - Nn) なる整数
            for n in range(1, 3501):
                for w in range(1, 3501):
                    numerator = N * n * w
                    denominator = 4 * n * w - N * n - N * w
                    if denominator > 0 and numerator % denominator == 0:
                        return (numerator // denominator), n, w
        
    
    N = ii()
    h, n, w = calc(N)
    print(f'{h} {n} {w}')


if __name__ == "__main__":
    main()

Submission status: Accepted

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    
    
    for h in range(1,3501):
        for n in range(1,3501):
            temp=(4*h*n-(n+h)*N)
            if temp>0:
                if ((N*h*n)%temp)==0:
                    print(h,n,(N*h*n)//temp)
                    exit()
    
                    
                    

main()

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
N=int(input())
h,n,w=0,0,0

for h in range(1,3*N//4+1):
  for w in range(3*N//4,3500+1):
    a = N*h*w
    b = 4*h*w-N*(w+h)
    if b==0:
      continue
    if a%b==0:
      n=a//b
      if 1<=n:
        print(h,n,w);exit()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
import sys
l = 3500
for a in range(1, l):
    for b in range(1, l):
        if (4*a*b - n*(a+b)) > 0 and n*a*b % (4*a*b - n*(a+b)) == 0:
            print(a, b, n*a*b // (4*a*b - n*(a+b)))
            sys.exit()

Submission status: Accepted

Solution code:
# C
import math
N = int(input())
flag = False
for h in range(1, 3501, 1):
    for n in range(1, 3501, 1):
        bumbo = 4 * h * n - N * h - N * n
        bunshi = N * h * n
        if bumbo == 0:
            continue
        wc = math.ceil(bunshi / bumbo)
        wf = math.floor(bunshi / bumbo)
        if wc == wf and wc >= 1:
            ans_h = h
            ans_n = n
            ans_w = wc
            flag = True
            break
    if flag:
        break
print(ans_h, ans_n, ans_w)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n = int(input())
# 4/N = 1/h+1/n + 1/w を満たすh,n,wを求めよ
# h,n,wは3500いかになる解が存在することは保証
# h,n,wを全探索で回したいがTLEなので、それを効率化して治める
# 順序は付けれるのでh<=n<=wとして良い
# ２つを固定できると二分探索を使って、O(log3500)に落とすことはできるが、それでも足りない
# 整数論的に考えると、ab+bc+ca/abcが4/nになるので
# gcd(ab+bc+ca,abc)がNがそれなりに大きい時結構大きくないといけないことがわかる。
# 解説をみるとh,nを固定するとwは一意に定まるので3500**2のオーダーでいける
for a in range(1,3501):
    for b in range(1,3501):
        if 4*a*b-n*b-n*a == 0: continue
        w = n*a*b/(4*a*b-n*b-n*a)
        # 整数判定
        if w == int(w) and w > 0:
            print(a,b,int(w))
            exit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
N = int(input())
for h in range(1,3501):
    for n in range(1,h):
        d = 4*h*n-N*n-N*h
        if d>0:
            w = N*h*n/d
            if w.is_integer():ans = [h,n,int(w)]
print(ans[0],ans[1],ans[2])

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

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

Submission status: Accepted

Solution code:
def main():
    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
            if numerator % denominator != 0:
                continue
            w = numerator // denominator
            if w <= 0:
                continue
            print(h, n, w)
            return

    print(-1)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    N = int(readline())
    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 int(w) == w and w > 0:
                    print(h, n, int(w))
                    exit()


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
from fractions import*
N=int(input())
# 4hnw=Nnw+Nhw+Nhn
for h in range(1,3501):
 for n in range(h,3501):
  x=4*h*n-N*n-N*h
  if x>0 and N*h*n%x==0:print(h,n,N*h*n//x),quit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# tenka1-2017-beginnerC - 4/N
# exhaustive search
def main():
    N = int(input())
    for h in range(N // 4 + 1, 3501):
        for n in range(N * h // (4 * h - N) + 1, 3501):
            numerator = N * h * n
            denominator = 4 * h * n - N * n - N * h
            if denominator > 0 and numerator % denominator == 0:
                w = numerator // denominator
                print(h, n, w)
                return


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    if b == 0:
        return a
    return gcd(b, a % b)


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


def main():
    N = int(input())
    MAX = 3501
    for h in range(1, MAX):
        gcdNh = gcd(N, h)
        for n in range(1, MAX):
            gcdNhn = gcd(gcdNh, n)
            denom = N * h * n // gcdNhn**2
            num = 4 * denom // N - denom // h - denom // n
            if num > 0 and denom % num == 0:
                w = denom // num
                print(h, n, w)
                return


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n=int(input())
def ac():
    for h in range(1,3501):
        for w in range(1,3501):
            try:
                num=(n*h*w)/(4*h*w-n*w-n*h)
                #正整数かどうかの判定
                if (num).is_integer() and num>0:
                    print("{} {} {}".format(h,w,int(num)))
                    return
            except:
                pass
if __name__=="__main__":
    ac()

Submission status: Accepted

Solution code:
def calc(h,n,N):
  if 4*h*n-N*(h+n)!=0:
    return (N*h*n)//(4*h*n-N*(h+n))
  else:
    return 0

N=int(input())
for h in range(1,3501):
  for n in range(1,3501):
    w=calc(h,n,N)
    if w>0:
      if 4/N==1/h+1/n+1/w:
        print(h,n,w)
        exit()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

flag = 0
for n in range(1,3500):
    if flag == 1:
        break
    for w in range(1,3500):
        if (4*n*w - N*w - N*n) == 0:
            continue
        h = N*n*w / (4*n*w - N*w - N*n)
        if h%1 == 0 and 1 <= h <= 3500:
            flag = 1
            break

print('{} {} {}'.format(int(h), n-1, w))

Submission status: Accepted

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

print(h,w,n)

Submission status: Accepted

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

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

Submission status: Accepted

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


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

    for h in range(1, 3500 + 1):
        for n in range(1, 3500 + 1):
            a = large_n * h * n
            b = 4 * h * n - large_n * (n + h)

            if b != 0:
                w, q = divmod(a, b)

                if q == 0 and w > 0:
                    print(h, n, 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):
   if (4*i*j-n*i-n*j)!=0:
    if (n*i*j)//(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 i in range(1,3501):
  for j in range(2,3501):
    p=4*i*j-n*(i+j)
    if p>0:
      q=n*i*j
      if q%p==0:
        print(i,j,q//p)
        exit()

Submission status: Accepted

Solution code:
n = int(input())

for x in range(1, 3500 + 1):
    for y in range(1, 3500 + 1):
        q = 4 * x * y - n * (x + y)     
        if q <= 0: continue

        p = n * x * y
        if p % q == 0:
            z = p // q
            print(x, y, z)
            exit()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
for a in range(1,3501):
    for b in range(a,3501):
        if 4/n <= 1/a + 1/b:
            continue
        if 4/n > 1/a + 2/b:
            break
        c = 1/(4/n - 1/a - 1/b)
        x = int(c)
        if 4/n == 1/a + 1/b + 1/x:
            print(a,b,x)
            exit()
        x = int(c)+1
        if 4/n == 1/a + 1/b + 1/x:
            print(a,b,x)
            exit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
def ok(h,n,w,N):
    if 4*h*n*w==N*(n*w+n*h+h*w):
        return 1
    else:
        return 0

def kiyaku(a,b):
    if b%a==0:
        return 1
    else:
        return 0

def solve(N):

    for i in range(N//4+1,3*N//4+1):
        for j in range(3*N//4+1,3501):
            if 4*i*j-N*(i+j)>0 and kiyaku(4*i*j-N*(i+j),N*i*j):
                return (i,j,N*i*j//(4*i*j-N*(i+j)))
h,n,w=solve(N)
print(h,n,w)

Submission status: Accepted

Solution code:
import sys

N = int(input())
for h in range(1, 3501):
    for n in range(1, h+1):
        if (4*h*n - N*h - N*n) <= 0:
            continue
        w_int = N*h*n // (4*n*h - N*h - N*n)
        w_float = N*h*n / (4*n*h - N*h - N*n)
        if w_int == w_float:
            print(h, n, w_int)
            sys.exit()

Submission status: Accepted

Solution code:
N=int(input())
s=False
for i in range(1,3501):
    for j in range(1,3501):
        if (4*i*j-N*i-N*j)>0:
            w=(N*i*j)/(4*i*j-N*i-N*j)
            if w%1==0:
                p=i
                q=j
                s=True
                break
    if s==True:
        break

print("{} {} {}".format(p,q,int(w)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

N = int(input())

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