P28623 [洛谷] Catch the Thieves
提高-
题目描述

Problem Background

You know, the security guards at a high school in Zhejiang are very dedicated (or so they seem). However, one day, a group of cows (don't ask me why) sneaked into the campus and entered the second canteen, where they stole and ate delicious meals (though they've never tasted them). The headmaster is very angry and has ordered the security guards to investigate this matter strictly. At this moment, *** walks by and, being diligent and meticulous, offers help to the security guards. Since *** is busy, the task is handed over to you. How about a cup of coffee first?

Problem Description

Karlven has heard that the security guards saw four cows rolling out of the school gate (too full to walk?) while on duty playing games. This breed of cows is very greedy and orderly. How do they show this? When stealing food, they line up, and the amount eaten by each subsequent cow is an integer multiple (let's say $k$, where $k > 1$) of the previous one. According to his experience, Karlven estimates that these cows can eat up to $m$ tons of food. If they exceed this limit, they will die instantly and turn to ashes. Therefore, a cow will not eat more than $m$ tons of food and can only eat one ton at a time. Once a cow cannot eat, it will attack its companions and then commit suicide. Now, Karlven does not tell you the value of $m$, but only informs you of the number of schemes $n$ ($n \leq 10^{15}$, don't panic) where the cows can steal food together and safely roll out of the school gate. Please calculate the value of $m$, and if there are multiple solutions, output the smallest possible value. If you cannot calculate it, output $-1$ and then complain to the security guards.

Input and Output Formats

Input Format

A single number $n$.

Output Format

Your calculated answer, a single integer.

Sample Input and Output

Sample Input #1

1

Sample Output #1

8

Sample Input #2

8

Sample Output #2

54

Notes

For $100\%$ of the data, $n \leq 10^{15}$.

Sample Explanation:

Sample #1: $(1, 2, 4, 8)$;

Sample #2: $(1, 2, 4, 8), (1, 3, 9, 27), (2, 4, 8, 16), (2, 6, 18, 54), (3, 6, 12, 24), (4, 8, 16, 32), (5, 10, 20, 40), (6, 12, 24, 48)$.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
1
样例输出
8