zoukankan      html  css  js  c++  java
  • hdu 5062(水题)

    Beautiful Palindrome Number

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


    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
     
    Source
     
    打表模拟
    #include <iostream>
    #include <stdio.h>
    #include <string.h>
    #include <stack>
    #include <vector>
    #include <algorithm>
    using namespace std;
    typedef long long LL;
    /*void init(int test)
    {
        int n = 1;
        for(int i=1; i<=test; i++)
        {
            n*=10;
        }
        int a[10],cnt=0;
        for(int i=1; i<=n; i++)
        {
            int m = i;
            int id = 1;
            while(m)
            {
                a[id++] = m%10;
                m/=10;
            }
            bool flag = true;
            for(int k=1,j=id-1; k<=j; k++,j--)
            {
                if(a[k]!=a[j])
                {
                    flag = false;
                    break;
                }
            }
            if(flag)
            {
                id = id-1;
                flag = true;
                for(int k=2; k<=id/2; k++)
                {
                    if(a[k]<=a[k-1]) flag = false;
                }
                if(id%2==1&&id!=1){
                    if(a[id/2]>=a[id/2+1]) flag = false;
                }
                if(flag) {
                    printf("%d
    ",i);
                    cnt++;
                }
            }
        }
        printf("%d
    ",cnt);
    }*/
    int a[]={1,9,18,54,90,174,258};
    int main()
    {
        /*int test;
        while(true){
        scanf("%d",&test);
        init(test);
        }*/
        int tcase;
        scanf("%d",&tcase);
        while(tcase--){
            int n;
            scanf("%d",&n);
            printf("%d
    ",a[n]);
        }
        return 0;
    }
  • 相关阅读:
    学习记录---KMP算法-部分匹配表理解
    关于GameObject无法禁用问题
    out用法
    关于Dictionary.TryGetValue的个人理解记录
    Transform.parent和Transform.root的区别
    Queue默认容量
    关于Camera Culling Mask
    MSVCP110.DLL没有被指定在WINDOWS上运行
    typeof instanceof 之间的区别总结
    Promise 使用心得
  • 原文地址:https://www.cnblogs.com/liyinggang/p/5656772.html
Copyright © 2011-2022 走看看