hdu 5062 Beautiful Palindrome Number(模拟)

Beautiful Palindrome Number

Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1062    Accepted Submission(s): 688


Problem Description
A positive integer x can represent as  (a1a2akaka2a1)10  or  (a1a2ak1akak1a2a1)10  of a 10-based notational system, we always call x is a Palindrome Number. If it satisfies  0<a1<a2<<ak9 , 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(1T7) , indicating the number of test cases.
Then T lines follow, each line represent an integer  N(0N6) .
 

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

Sample Input
  
  
2 1 6
 

Sample Output
  
  
9 258
题意:1~10的n次方有几个上升的回文数

思路:直接模拟,当然像我这样打表也行,n只有6

代码:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
/*int a[10];
int check(int x)
{
    int l=x,ans=0;
    int num=0;
    while(l)
    {
        ans=ans*10+l%10;
        l/=10;
        num++;
    }
    if(ans!=x) return 0;
    if(num&1) num++;
    num/=2;
    int now=-1;
    while(num--)
    {
        int w=x%10;
        if(w<=now) return 0;
        now=w;
        x/=10;
    }
    return 1;
}
void init()
{
    int num=0;
    for(int i=1;i<=100;i++)
    {
        if(check(i))
            num++;
    }
    printf("%d\n",num);
}*/
int main()
{
    int T,n;
    //init();
    scanf("%d",&T);
    while(T--)
    {
        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 printf("258\n");
    }
    return 0;
}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值