CF991F.Concise and clear
省选/NOI-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Vasya is a regular participant at programming contests and is already experienced in finding important sentences in long statements. Of course, numbers constraints are important — factorization of a number less than 1000000 is easier than of a number less than 1000000000. However, sometimes it's hard to understand the number at the first glance. Could it be shortened? For example, instead of 1000000 you could write 106, instead of 1000000000 —109, instead of 1000000007 — 109+7.
Vasya decided that, to be concise, the notation should follow several rules:
- the notation should only consist of numbers, operations of addition ("+"), multiplication ("*") and exponentiation ("^"), in particular, the use of braces is forbidden;
- the use of several exponentiation operations in a row is forbidden, for example, writing "234" is unacceptable;
- the value of the resulting expression equals to the initial number;
- the notation should consist of the minimal amount of symbols.
Given n, find the equivalent concise notation for it.
瓦西里是编程竞赛的常客,早已熟练于在冗长的题目描述中找出关键句。当然,数据范围很重要——分解一个小于 1000000 的数,比分解一个小于 1000000000 的数要容易得多。然而,有时仅凭第一眼很难理解某个数字的量级。能否将其简写呢?例如,用 106 代替 1000000,用 109 代替 1000000000,用 109+7 代替 1000000007。
瓦西里决定,为保证简洁性,该简写记法需满足以下规则:
- 记法中仅可包含数字、加法(“+”)、乘法(“*”)和幂运算(“^”)运算符;特别地,不允许使用括号;
- 不允许连续使用多个幂运算符,例如,“234” 是不合法的;
- 该表达式的计算结果必须严格等于原数;
- 该表达式所含字符总数应为最小可能值。
给定正整数 n,请找出其满足上述条件的最短等价简写表达式。
输入格式
The only line contains a single integer n (1≤n≤10000000000).
唯一的一行包含一个整数 n(1≤n≤10000000000)。
输出格式
Output a concise notation of the number n. If there are several concise notations, output any of them.
输出数字 n 的简洁表示法。如果存在多种简洁表示法,则输出其中任意一种。
输入输出样例
输入#1
2018
输出#1
2018
输入#2
1000000007
输出#2
10^9+7
输入#3
10000000000
输出#3
100^5
输入#4
2000000000
输出#4
2*10^9
说明/提示
The third sample allows the answer 10^10 also of the length 5.
第三个样例允许答案 1010,其长度也为 5。
输入解题思路,AI测评打分。不知道怎么写?