没有合适的资源?快使用搜索试试~ 我知道了~
思路:给出的数n是十进制,不论是几进制的表示法,都可以用以下公式得到数n1 + base + base^2 + base^3+...+base^(bit-1)
资源详情
资源评论
资源推荐
Problem
We consider a number to be beautiful if it consists only of the digit 1 repeated one or more
times. Not all numbers are beautiful, but we can make any base 10 positive integer
beautiful by writing it in another base.
Given an integer N, can you find a base B (with B > 1) to write it in such that all of its digits
become 1? If there are multiple bases that satisfy this property, choose the one that
maximizes the number of 1 digits.
Input
The first line of the input gives the number of test cases, T. T test cases follow. Each test
case consists of one line with an integer N.
Output
For each test case, output one line containing Case #x: y, where x is the test case
number (starting from 1) and y is the base described in the problem statement.
Limits
1 ≤ T ≤ 100.
Small dataset
3 ≤ N ≤ 1000.
Large dataset
3 ≤ N ≤ 10
18
.
Sample
Input
Output
2
3
13
Case #1: 2
Case #2: 3
In case #1, the optimal solution is to write 3 as 11 in base 2.
In case #2, the optimal solution is to write 13 as 111 in base 3. Note that we could also
write 13 as 11 in base 12, but neither of those representations has as many 1s.
我就是月下
- 粉丝: 25
- 资源: 336
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0