hihoCoder 1432 : JiLi Number(吉利数)
hihoCoder #1432 : JiLi Number(吉利数)
Description - 题目描述
Driver Ji likes the digit "1". He has an accumulator which shows the sum of input number. He lists all of positive number no more than N and starts counting from one, two, three...Every time he counts a number he will add the number of digit "1" in this number to accumulator at the same time. The amazing thing happens! At some times, when he finishes counting a number X, the number which on the accumulator is X exactly, he will regard X as "JiLi Number" which means lucky number. Now he wants to know the number of "JiLi Numbers" and the biggest "JiLi Number" no more than N.
Ji司机喜欢数字””。他有一个累加器可以显示输入数的和。他列出了所有不超过N的正整数,并且开始1,,...地数了起来。每当他数到一个数时,会顺手把其数字””的个数放入累加器。不可思议的事发生了!有时他数完一个数X,累加器中的数也恰好为X,他将X称作”吉利数”,表示十分幸运的数字。现在他想知道在不超过N的情况下”吉利数”的数量与最大”吉利数”。
CN
Input - 输入
There are several test cases and the each test case is a line contains an positive integer N.(1<N≤10100)
多组数据,每组数据仅有一行,每行一个正整数N。(<N≤^)
CN
Output - 输出
For each test case, output two integers which donates the number of "JiLi Numbers" and the biggest "JiLi Number".
对于每个测试用例,输出两个整数分别表示”吉利数”的数量与最大的”吉利数”。
CN
Sample Input - 样例输入
1
100000000000
Sample Output - 样例输出
1 1
83 1111111110
题解
暴力枚举,样例刚刚好给出了最大与最小的情况……
至于证明,证不出来,似乎因为是十进制数所以不能超过十位数,到了后面累加器中的值的增长速度明显超过了数数速度,应该是没有交集了……
代码 C++
#include<cstdio>
#include <algorithm>
#define ll long long
#define mx 84
ll opt[mx] = {
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
0x7FFFFFFFFFFFFFFF
};
int main(){
char rd[];
int i;
ll tmp;
while (gets(rd)){
tmp = ;
for (i = ; i < && rd[i]; ++i) tmp = tmp * + rd[i] - '';
i = std::upper_bound(opt, opt + mx, tmp) - opt;
printf("%d %lld\n", i, opt[i - ]);
}
return ;
}
hihoCoder 1432 : JiLi Number(吉利数)的更多相关文章
- [LeetCode] Ugly Number 丑陋数
Write a program to check whether a given number is an ugly number. Ugly numbers are positive numbers ...
- [LeetCode] Strobogrammatic Number 对称数
A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside ...
- [LeetCode] Happy Number 快乐数
Write an algorithm to determine if a number is "happy". A happy number is a number defined ...
- Ugly number丑数2,超级丑数
[抄题]: [思维问题]: [一句话思路]:Long.valueOf(2)转换为long型再做 [输入量]:空: 正常情况:特大:特小:程序里处理到的特殊情况:异常情况(不合法不合理的输入): [画图 ...
- hdu 3709 Balanced Number(平衡数)--数位dp
Balanced Number Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others) ...
- [LeetCode] 263. Ugly Number 丑陋数
Write a program to check whether a given number is an ugly number. Ugly numbers are positive numbers ...
- [LeetCode] 136. Single Number 单独数
Given a non-empty array of integers, every element appears twice except for one. Find that single on ...
- [LeetCode] 202. Happy Number 快乐数
Write an algorithm to determine if a number is "happy". A happy number is a number defined ...
- [LeetCode] 246. Strobogrammatic Number 对称数
A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside ...
随机推荐
- sqlserver日志的备份与还原
----------完整备份与还原---------- --完整备份数据库--backup database studb to disk='e:\stu.bak'back ...
- Web自动化测试工具调研
背景 Web自动化测试越来越被重视, 因为现在Web已经是工程化的状态. 如何通过工具测试, 保证Web开发的质量,提升开发效率,是Web工具的诞生的来由. Web测试分为以下几个方面: 1. 界面测 ...
- 前端forEach在Array、map、set中的使用
数组: var s = ['a','b','c']; s.forEach(function(ele,index,array){ console.log(ele); }); Map: var map = ...
- 服务器支持AspJpeg和JMail45_free.msi组件
解决办法: 1.在服务器上安装上AspJpeg和JMail45_free.msi后, 2.在cmd中输入regsvr32 c:/windows/SysWOW64/aspjpeg.dll 3.把网站对 ...
- .net post的参数如果出现乱码如何解决!
可以在webConfig里面添加 <system.web> <globalization requestEncoding="gb2312" responseEnc ...
- SVN强制退出,出现被锁的情况解决方法
1. 打开终端 输入cd Desktop enter之后 输入ls enter键 2. 输入cd 文件名(比如IOS)enter键 3. 输入LS enter 4. find . | grep &q ...
- Windows Azure Virtual Machine 之用程序控制Azure VM
我们在很多时候可能会需要用程序来控制VM的创建,删除工作. 而在这些工作之中,用程序创建一个VM将会是一个非常复杂的过程,因为他涉及到很多步骤. 具体步骤如下 1 创建一个Hosted cloud s ...
- presto的动态化应用(一):presto节点的横向扩展与伸缩
一.presto动态化概述 近年来,基于hadoop的sql框架层出不穷,presto也是其中的一员.从2012年发展至今,依然保持年轻的活力(版本迭代依然很快),presto的相关介绍,我们就不赘述 ...
- C语言-自定义函数
C语言自定义函数 --1-- 自定义函数定义 1.1 无参无返回值函数 1.2 无参有返回值函数 1.3 有参无返回值函数 1.4 有参有返回值函数 --2-- 函数的参数 2.1 形式参数介绍和使用 ...
- android源码中修改wifi热点默认始终开启
在项目\frameworks\base\wifi\java\android\net\wifi\WifiStateMachine.java里面,有如下的代码,是设置wifi热点保持状态的:如下: pri ...