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: Runtime Error

Solution code:
N = int(input())                                                                                                               
mx = 3501                                                                                                                      
                                                                                                                               
def func():                                                                                                                    
    for x in range(1, mx):                                                                                                     
        for y in range(x, mx):                                                                                                 
            if (2*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: Runtime Error

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

Submission status: Runtime Error

Solution code:
# 4/N

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
N = input()

hnw = 0.75 * N

each = hnw / 3

h = each
n = each
w = each
print(h,end="")
print(n,end="")
print(w,end="")

Submission status: Runtime Error

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

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

main()

Submission status: Runtime Error

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 get_a(N):
    a = 1
    while True:
        if N < 4 * a:
            return a, 4*a-N, N*a
        a += 1

def get_b(N1, N2):
    b = 1
    while True:
        if N2 < b * N1:
            return b, b*N1-N2, b*N2
        b += 1

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

def solve(N):
    a, N1, N2 = get_a(N)
    # print("a,N1,N2 = ", a, N1, N2)
    b, N1, N2 = get_b(N1, N2)
    # print("b,N1,N2 = ", b, N1, N2)
    g = gcd(N1,N2)
    N1 //= g
    N2 //= g
    assert(N1 == 1)
    print(a, b, N2)

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

solve(N)

Submission status: Runtime Error

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