HDU 2575 Count Problem (水题)
来源:互联网 发布:windows ad域搭建 编辑:程序博客网 时间:2024/05/16 09:25
Problem Description
In this problem,we need to count the number that accord with the following rule(include the input number n).Read a integer number n(1<=n<=2^31 - 1) first,then do as following ways:
(1)Do nothing, then exit the process.
(2)Add a digit to the left of it,but the digit should not bigger than the half of the original first digit.For example,from 36 to 136 is legal,but 36 to 236 is illegal because 2 is bigger than half of 3.
(3)After add the digit,continue the process,until could not add digit anymore.
Input
The first line of the input contains an integer T which means the number of test cases.Then T lines follow, each line starts with a number n(1<=n<=2^31 - 1).
Output
For each test case, you should output one line contains the number that accord with the rule start from n.
Sample Input
2
1
6
Sample Output
1
6
Hint
The first case 1 cannot any digital to the leftmost, so the number so only 1.
In this problem,we need to count the number that accord with the following rule(include the input number n).Read a integer number n(1<=n<=2^31 - 1) first,then do as following ways:
(1)Do nothing, then exit the process.
(2)Add a digit to the left of it,but the digit should not bigger than the half of the original first digit.For example,from 36 to 136 is legal,but 36 to 236 is illegal because 2 is bigger than half of 3.
(3)After add the digit,continue the process,until could not add digit anymore.
Input
The first line of the input contains an integer T which means the number of test cases.Then T lines follow, each line starts with a number n(1<=n<=2^31 - 1).
Output
For each test case, you should output one line contains the number that accord with the rule start from n.
Sample Input
2
1
6
Sample Output
1
6
Hint
The first case 1 cannot any digital to the leftmost, so the number so only 1.
The second case 6 can add 1, 2, 3 to the leftmost so 16,26,36 are legal. And then 26, 36 also can add 1 to the leftmost so get 126, 136. So 6,16,26,36,126,136 are all legal.The result is 6.
题意:给定一个数n,从n的左边开始添加整数,要求添加的整数满足不大于n的最高位(first digit)的一半,直到不能添加为止;
比如 n=6,满足条件的有6、16、26、36、126、136共6种情况;
n=10;只有10一种情况,因为10的最高位为1,
故只需要穷举n从1~9共9种情况,
以下AC代码:
#include<stdio.h> int main() { int t,n,a[10]={0,1,2,2,4,4,6,6,10,10}; scanf("%d",&t); while(t--) { scanf("%d",&n); while(n>9) n/=10; printf("%d\n",a[n]); } return 0; }
0 0
- HDU 2575 Count Problem (水题)
- hdu 2575 Count Problem (水)
- Problem - 3777 Page Count
- fdu Problem 2072 Count
- Pop Count Problem
- Problem 2072 Count
- Count The Carries - HDU 4588 水题
- 【HDU 3199】【水题】Hamming Problem
- hdu 5686 Problem B【水题】
- HDU 1001 Sum Problem 水题
- [HDU-5980] [Problem J]水题
- A+B Problem (Case Count)
- A+B Problem (Case Count)
- A+B problem(case count)
- HDU-PROBLEM
- Count 101 hdu 3485
- hdu 1223 Order Count
- HDU 4472 Count
- 《C语言程序设计(第二版新版)》第一章习题解答(部分)
- Android Service解析
- java常见基础知识汇总
- hdu1565方格取数(1) (最大权独立集)
- POJ 1144 Network【割点个数】
- HDU 2575 Count Problem (水题)
- 虚拟机无法识别U盘的问题及解决方法
- 学习笔记:Ubuntu15.04 + Python 配置
- Android基于蓝牙的聊天demo
- 全排列函数
- 翻转子串(思路:假定两个字符串已经是翻转)
- android开发内存溢出处理记录
- 【eclipse】generate getters and setters错误
- android开发中Rsa加密的使用