落絮飞雁

顺流而下,把梦做完

HDOJ5062:Beautiful Palindrome Number

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 and 10N.

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 integer N(0≤N≤6).

Output
For each test case, output the number of Beautiful Palindrome Number.

Sample Input
2
1
6

Sample Output
9
258


要求判断范围内有多少回文串。由于范围小,可以直接打表计算。

#include
int main()
{
	int a[7]={1,9,18,54,90,174,258},t,n;
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d",&n);
		printf("%dn",a[n]);
	}
return 0;
}

 


原文标题:HDOJ5062:Beautiful Palindrome Number|落絮飞雁的个人网站
原文链接:https://www.luoxufeiyan.com/2014/12/18/hdoj5062%ef%bc%9abeautiful-palindrome-number/
授权协议:创作共用 署名-非商业性使用 2.5 中国大陆
除注明外,本站文章均为原创;转载时请保留上述链接。