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;
}

 

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注