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. Java c3p0连接池

    import java.beans.PropertyVetoException; import java.sql.Connection; import java.sql.SQLException; i ...

  2. sh脚本异常:/bin/sh^M:bad interpreter: No such file or directory

    在Linux中执行.sh脚本,异常/bin/sh^M: bad interpreter: No such file or directory. 分析:这是不同系统编码格式引起的:在windows系统中 ...

  3. Spring jar下载地址:

    https://repo.spring.io/release/org/springframework/spring/

  4. 论AVL树与红黑树

    首先讲解一下AVL树: 例如,我们要输入这样一串数字,10,9,8,7,15,20这样一串数字来建立AVL树 1,首先输入10,得到一个根结点10 2,然后输入9, 得到10这个根结点一个左孩子结点9 ...

  5. 配置java环境 ,安装Android Studio...(ps:用eclipse也不错,但as是趋势 自己凭爱好选择)

    to:青科大可爱的学弟学妹: 配置java环境 step1:下jdk 直接打开链接即可(ps:复制链接到迅雷下载更快哦) 64位的:http://download.oracle.com/otn-pub ...

  6. android手机和ios手机的分辨率

    Android手机目前常见的分辨率 1.1 手机常见分辨率: 4:3 VGA     640*480 (Video Graphics Array) QVGA  320*240 (Quarter VGA ...

  7. c#-二分查找-算法

    折半搜索,也称二分查找算法.二分搜索,是一种在有序数组中查找某一特定元素的搜索算法. A 搜素过程从数组的中间元素开始,如果中间元素正好是要查找的元素,则搜素过程结束: B 如果某一特定元素大于或者小 ...

  8. .net之工作流工程展示及代码分享(二)工作流引擎

    在介绍完表单类的时候,接下来介绍工作流引擎,主要由四个类组成,分别是流程.流程步骤.流程实例.流程步骤实例类. 流程类: [Serializable] public class Flow { [Xml ...

  9. 一个java的Profile工具

    场景:我们在系统运行中,需要监控某个代码段的运行时间,我们完全可以使用currentTimeMillis来做,但是做起来比较麻烦,尤其是需要阶段监控的时候,那么这个工具就出现啦~~~ 先说下想要实现的 ...

  10. powerDesigner生成excel版本的数据库文件

    今天收到一个需求,要把数据库设计给一个excel版本的,百度出来一个脚本文件,很好用发现,留个纪念 在pd中,shift+ctrl+X,打开脚本运行,脚本如下,附件也留了一份: '********** ...