1 #include <iostream> 2 #include <cstdio> 3 #include<cstdlib> 4 using namespace std; 5 6 int main() 7 { 8 freopen("ACM.txt","r",stdin); 9 int t; 10 cin>>t; 11 while(t--) 12 { 13 int a=1,n,ans=0; 14 cin>>n; 15 for(int i=0;i<n;i++) a*=10; 16 for(int i=1;i<=a;i++) 17 { 18 int m=i,c=i,b=-1,sum=0,p=1,s=i/10; 19 while(m) 20 { 21 sum=sum*10+m%10; 22 m/=10; 23 } 24 if(sum==i) 25 ans++; 26 } 27 cout<<ans<<endl; 28 } 29 return 0; 30 }
来源:https://www.cnblogs.com/M-D-LUFFI/p/4019822.html