hdu 5062 Beautiful Palindrome Number(Bestcodeer Round #13)
来源:互联网 发布:淘宝一天十个访客 编辑:程序博客网 时间:2024/05/16 14:35
Beautiful Palindrome Number
Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 116 Accepted Submission(s): 82
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
结果就只有七个,交上去一个表就行了,n最大为6,暴力代码也能过。附上打表代码和暴力代码。
打表代码:
//0ms#include <cstdio>#include <cstring>#include <iostream>int a[7]={1,9,18,54,90,174,258};int main(){ int t,n; scanf("%d",&t); while(t--) { scanf("%d",&n); printf("%d\n",a[n]); }}
暴力代码:
//46ms#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;int a[10];bool judge(int x){ int n=0; while(x>0) { a[++n]=x%10; x=x/10; } //printf("%d\n",n); if(a[1]!=a[n]) return false; for(int j=2,k=n-1;j<=k;j++,k--) { if(a[j]>a[j-1]&&a[j]==a[k]) ; else return false; } return true;}int main(){ int t,n; scanf("%d",&t); while(t--) { scanf("%d",&n); int temp=1; int ans=0; for(int i=1;i<=n;i++) { temp*=10; } //printf("%d",temp); for(int i=1;i<=temp;i++) { if(judge(i)) { ans++; } } printf("%d\n",ans); } return 0;}
0 0
- HDU-#5062 Beautiful Palindrome Number(Bestcodeer Round #13)
- hdu 5062 Beautiful Palindrome Number(Bestcodeer Round #13)
- HDU 5062 Beautiful Palindrome Number——BestCoder Round #13
- 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(数学题)
- hdu 5062 Beautiful Palindrome Number( dp )
- HDU 5062Beautiful Palindrome Number(暴力)
- BestCoder Round #13 Beautiful Palindrome Number解题报告
- HDOJ 5062 Beautiful Palindrome Number
- 【CUGBACM15级BC第13场 A】hdu 5062 Beautiful Palindrome Number
- 【BestCoder】HDOJ 5062 Beautiful Palindrome Number
- Beautiful Palindrome Number(回文数)
- Beautiful Palindrome Number 美丽的回文数 HD 5062
- hdu5062——Beautiful Palindrome Number(模拟)
- 大学(2)
- git tips - merge, revert
- 劣质代码产生的八个原因
- python 基本内容
- 【C++】【STL】STL学习之旅一:命名空间
- hdu 5062 Beautiful Palindrome Number(Bestcodeer Round #13)
- Linux 下手动挂载U盘命令
- Vijos.1096 津津的储蓄计划
- 【C++】【STL】STL学习之旅二:模板
- Anatomy of a Program in Memory
- 【C++】学习C++和编程的50个观点
- halcon学习6,可视化条码扫描的例子学习
- hdu 5063 Operation the Sequence(Bestcoder Round #13)
- pyhon3模拟登录百度(2)—— 使用IE11理清百度登录内部逻辑和分析请求发送数据