hihoCoder #1432 : JiLi Number(吉利数)

时间限制:1000ms
单点时限:1000ms
内存限制:256MB

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(吉利数)的更多相关文章

  1. [LeetCode] Ugly Number 丑陋数

    Write a program to check whether a given number is an ugly number. Ugly numbers are positive numbers ...

  2. [LeetCode] Strobogrammatic Number 对称数

    A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside ...

  3. [LeetCode] Happy Number 快乐数

    Write an algorithm to determine if a number is "happy". A happy number is a number defined ...

  4. Ugly number丑数2,超级丑数

    [抄题]: [思维问题]: [一句话思路]:Long.valueOf(2)转换为long型再做 [输入量]:空: 正常情况:特大:特小:程序里处理到的特殊情况:异常情况(不合法不合理的输入): [画图 ...

  5. hdu 3709 Balanced Number(平衡数)--数位dp

    Balanced Number Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others) ...

  6. [LeetCode] 263. Ugly Number 丑陋数

    Write a program to check whether a given number is an ugly number. Ugly numbers are positive numbers ...

  7. [LeetCode] 136. Single Number 单独数

    Given a non-empty array of integers, every element appears twice except for one. Find that single on ...

  8. [LeetCode] 202. Happy Number 快乐数

    Write an algorithm to determine if a number is "happy". A happy number is a number defined ...

  9. [LeetCode] 246. Strobogrammatic Number 对称数

    A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside ...

随机推荐

  1. Excel Note

    公式的引用分为相对引用.绝对引用和混合引用.如果要使公式中的引用随着公式的下拉改变就用相对引用.如=sum(A2:D20),这个公式下拉时引用的单元格就会随着变化.如果要使公式中的引用下拉时不会改变就 ...

  2. Eclipse开发快捷键技巧

    1.alt+?或alt+/:自动补全代码或者提示代码 这个是我最得意的快捷键组合了,尤其是当输入syso几个字符之后,2个手指轻松按下这2个键的时候,自动就补全System.out.println() ...

  3. linux/unix 编程手册 fork()函数

    父进程通过fork()函数创建子进程,将父进程数据段和栈的内容拷贝到子进程中,子进程执行程序execve创建新程序,调用exit函数退出到等待wait(),挂起父进程, 父子进程享用相同的程序文本段. ...

  4. 【皇甫】☀初识AOP

    新知识,新起点,下面介绍一下aop所要准备架包和各个层 特点: 创建好的各个层: 所需架包: 具体步骤: No.1  搭建分层架构 entity 1 public class User impleme ...

  5. Windows Phone 十、数据绑定

    数据绑定:是一种 XAML 和后台数据交互的方式(桥梁) 通过后台进行数据绑定 <Grid> <TextBox x:Name="txtHello" Text=&q ...

  6. Install Jenkins Slave as Windows Service

    https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+as+a+Windows+service SC 直接创建windows s ...

  7. virtualenv 安装 lxml

    sudo apt-get install zlib1g-dev sudo apt-get install lib32z1-dev sudo apt-get install libxml2-dev li ...

  8. 设置 phoneGap/Cordova 3.4 应用程序启动动画闪屏 SplashScreen

    当Cordova 程序打包并安装到手机中后,我们会发现启动程序时,会有数秒的黑屏现象,常见的解决方法则是设置闪屏后面. 这里以 Android 程序为例,介绍Cordova设置启动画面的方法. 1. ...

  9. 集群间Session共享问题解决方案

    两个基本概念的生命周期 session: 当新客户端发现一个HTTP请求时服务端会创建一个session.并分配一个sessionID作为服务端来客户端的识别,session对象会保存在服务端.此时s ...

  10. 调试必备---console

    一.前言 可能很多前端er会习惯用 alert() 方法来进行调试,但我相信更多的人会使用 console.log(),因为它不用像 alert() 那样会有字符长度限制,也不会中止程序的进程,而且还 ...