A8049 | Sum
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Vasya studies positional numeral systems. Unfortunately, he often forgets to write the base of notation in which the expression is written. Once he saw a note in his notebook saying $a+b=?$ , and that the base of the positional notation wasn’t written anywhere. Now Vasya has to choose a base $p$ and regard the expression as written in the base $p$ positional notation. Vasya understood that he can get different results with different bases, and some bases are even invalid. For example, expression $78+87$ in the base 16 positional notation is equal to $FF_{16}$ , in the base 15 positional notation it is equal to $110_{15}$ , in the base 10 one — to $165_{10}$ , in the base 9 one — to $176_{9}$ , and in the base 8 or lesser-based positional notations the expression is invalid as all the numbers should be strictly less than the positional notation base. Vasya got interested in what is the length of the longest possible expression value. Help him to find this length.
The length of a number should be understood as the number of numeric characters in it. For example, the length of the longest answer for $78+87=?$ is 3. It is calculated like that in the base 15 ( $110_{15}$ ), base 10 ( $165_{10}$ ), base 9 ( $176_{9}$ ) positional notations, for example, and in some other ones.
The length of a number should be understood as the number of numeric characters in it. For example, the length of the longest answer for $78+87=?$ is 3. It is calculated like that in the base 15 ( $110_{15}$ ), base 10 ( $165_{10}$ ), base 9 ( $176_{9}$ ) positional notations, for example, and in some other ones.
输入格式
The first letter contains two space-separated numbers $a$ and $b$ ( $1<=a,b<=1000$ ) which represent the given summands.
输出格式
Print a single number — the length of the longest answer.
输入输出样例
输入 #1
78 87
输出 #1
3
输入 #2
1 1
输出 #2
2
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted