hdu5062——Beautiful Palindrome Number(模拟)
2017-04-02 16:18
344 查看
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
输入只有其中情况,可以事先算出来,直接把答案存到数组里
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 <iostream> #include <cstring> #include <string> #include <vector> #include <queue> #include <cstdio> #include <set> #include <math.h> #include <algorithm> #include <queue> #include <iomanip> #define INF 0x3f3f3f3f #define MAXN 6005 #define Mod 99999999 using namespace std; int main() { /*for(int n=0; n<=6; ++n) { int len=pow(10,n),ans=0; for(int i=1; i<=len; ++i) { if(i>=1&&i<=9) ans++; else if(i>=10&&i<=99) { int a=i/10,b=i%10; if(a==b) { ans++; //cout<<i<<endl; } } else if(i>=100&&i<=999) { int a=i/100,b=(i/10)%10,c=i%10; if(a<b&&a==c) { ans++; //cout<<i<<endl; } } else if(i>=1000&&i<=9999) { int k1=i/1000,k2=(i/100)%10,k3=(i/10)%10,k4=i%10; if(k1==k4&&k2==k3&&k1<k2) { ans++; //cout<<i<<endl; } } else if(i>=10000&&i<=99999) { int k1=i/10000,k2=(i/1000)%10,k3=(i/100)%10,k4=(i/10)%10,k5=i%10; if(k1==k5&&k2==k4&&k1<k2&&k2<k3) { ans++; cout<<i<<endl; } } else if(i>=100000&&i<=999999) { int k1=i/100000,k2=(i/10000)%10,k3=(i/1000)%10,k4=(i/100)%10,k5=(i/10)%10,k6=i%10; if(k1==k6&&k2==k5&&k3==k4&&k1<k2&&k3<k4&&k2<k3) { ans++; //cout<<i<<endl; } } } cout<<n<<" "<<len<<" "<<ans<<endl; } return 0;*/ int a[]={1,9,18,54,90,174,258}; int t; cin>>t; while(t--) { int n; cin>>n; cout<<a <<endl; } }
相关文章推荐
- 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(暴力)
- 【CUGBACM15级BC第13场 A】hdu 5062 Beautiful Palindrome Number
- hdu 5062 Beautiful Palindrome Number(水题)
- hdu 5062 Beautiful Palindrome Number( dp )
- HDU 5062 Beautiful Palindrome Number(暴力)
- HDU 5062 Beautiful Palindrome Number(数学题)
- HDU 5062 Beautiful Palindrome Number——BestCoder Round #13
- HDU-#5062 Beautiful Palindrome Number(Bestcodeer Round #13)
- Beautiful Palindrome Number 美丽的回文数 HD 5062
- 【BestCoder】HDOJ 5062 Beautiful Palindrome Number
- HDOJ 5062 Beautiful Palindrome Number
- HDU-1394-Minimum Inversion Number(最小逆序数-模拟)
- hdu 4608 I-number 模拟
- hdu 4727 The Number Off of FFF(模拟)
- HDU 4608 I-number(模拟)
- HDU 5611 Baby Ming and phone number(字符串模拟)