HDU 5062 Beautiful Palindrome Number(数学题)
来源:互联网 发布:淘宝开店保证金交不了 编辑:程序博客网 时间:2024/04/30 09:55
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5062
Problem Description
A positive integer x can represent as (a1a2…akak…a2a1)10 or (a1a2…ak−1akak−1…a2a1)10 of a 10-based notational system, we always call x is a Palindrome Number. If it satisfies 0<a1<a2<…<ak≤9 , we call x is a Beautiful Palindrome Number.
Now, we want to know how many Beautiful Palindrome Numbers are between 1 and10N .
Now, we want to know how many Beautiful Palindrome Numbers are between 1 and
Input
The first line in the input file is an integer T(1≤T≤7) , indicating the number of test cases.
Then T lines follow, each line represent an integerN(0≤N≤6) .
Then T lines follow, each line represent an integer
Output
For each test case, output the number of Beautiful Palindrome Number.
Sample Input
216
Sample Output
9258
Source
BestCoder Round #13
题意:
求1到10的n次方的范围内,满足:
1、是回文数;
2、回文的前半部分满足升序;
打表代码:
#include <cstdio>#include <cstring>int find_num(int num){ int a[17]; memset(a,0,sizeof(a)); int L = 0; while(num) { a[++L] = num%10; num/=10; } for(int i = 1; i <= L/2; i++)//回文 { if(a[i] != a[L-i+1]) return 0; } for(int i = 1; i < L/2+L%2; i++)//升序 { if(a[i+1] <= a[i]) return 0; } return 1;}int main(){ int sum[17]; memset(sum,0,sizeof(sum)); sum[0] = 1; for(int i = 1; i <= 1000000; i++) { int flag = find_num(i); if(flag) { //printf("num::%d\n",i); if(i <= 10) sum[1]++; if(i <= 100) sum[2]++; if(i <= 1000) sum[3]++; if(i <= 10000) sum[4]++; if(i <= 100000) sum[5]++; if(i <= 1000000) sum[6]++; } } int t; for(int i = 0; i <= 6; i++) { printf("%d::%d\n",i,sum[i]); } return 0;}
代码如下:
#include <cstdio>int main(){ int t; scanf("%d",&t); while(t--) { int n; scanf("%d",&n); if(n == 0) printf("1\n"); else if(n == 1) printf("9\n"); else if(n == 2) printf("18\n"); else if(n == 3) printf("54\n"); else if(n == 4) printf("90\n"); else if(n == 5) printf("174\n"); else if(n == 6) printf("258\n"); } return 0;}
2 0
- HDU 5062 Beautiful Palindrome Number(数学题)
- HDU 5062 Beautiful Palindrome Number
- HDU 5062 Beautiful Palindrome Number(暴力)
- hdu 5062 Beautiful Palindrome Number(水题)
- HDU——5062 Beautiful Palindrome Number
- hdu 5062 Beautiful Palindrome Number( dp )
- HDU 5062Beautiful Palindrome Number(暴力)
- hdu 5062 Beautiful Palindrome Number(模拟)
- HDU-#5062 Beautiful Palindrome Number(Bestcodeer Round #13)
- hdu 5062 Beautiful Palindrome Number(Bestcodeer Round #13)
- HDU 5062 Beautiful Palindrome Number——BestCoder Round #13
- HDOJ 5062 Beautiful Palindrome Number
- 【BestCoder】HDOJ 5062 Beautiful Palindrome Number
- 【CUGBACM15级BC第13场 A】hdu 5062 Beautiful Palindrome Number
- hdu 3418 Beautiful Dream数学题
- Beautiful Palindrome Number 美丽的回文数 HD 5062
- hdu(5179):beautiful number
- hdu 5179-beautiful number
- 程序员的故事
- 日语学习之沪江整理 20141025
- UILabel iOS中添加文字的控件
- Android文件上传
- Android自动化测试工具之monkeyrunner 介绍
- HDU 5062 Beautiful Palindrome Number(数学题)
- 计蒜客 挑战难题 第16题:爬楼梯
- C++ 虚函数
- 使用 Struts 2 开发 RESTful 服务
- Stanford机器学习---第十讲. 数据降维
- IN 函数 和 and 在where条件中联合使用的注意事项:
- AT+CNMI
- 最近公共祖先 (Lowest common ancestor)
- Java探索之旅(5)——数组