Time limit
1s
Memory limit
128 MB
Consider a sequence made of positive integers. The length of a sequence is defined as the number of integers it contains.
Given a positive integer M, solve the following two tasks independently.
Task A: Among all positive-integer sequences whose sum is M, choose one whose product of all elements is as large as possible. In other words, satisfy a1 + a2 + ... + an = M while maximizing a1 * a2 * ... * an. If maximum-product sequences exist with more than one length, choose a sequence with the largest length n.
Task B: Among all positive-integer sequences whose product is M, choose one whose sum of all elements is as small as possible. In other words, satisfy a1 * a2 * ... * am = M while minimizing a1 + a2 + ... + am. If minimum-sum sequences exist with more than one length, choose a sequence with the smallest length m.
Find the length n chosen for Task A and the length m chosen for Task B.
The first line contains an integer M.
1 <= M <= 1,000,000
Print the length n from Task A and the length m from Task B, separated by one space.