Blue Bridge cup - (a palindrome)

 Problem Description
  123321 is a very special number, it is read from left to right and read from the same.
  Enter a positive integer n, find all such programming five and six decimal numbers, figures and meet all equal to n.
 
Input format
  input line, contains a positive integer n.
Output format
  in order from small to large outputs an integer satisfying the condition, each integer per line.
 
Input Sample
52
Sample Output
899 998
989 989
998 899
 
data size and Conventions
  1 <= n <= 54.

 

The problem of violence can run

AC Code:

#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
inline int read() {int x=0,f=1;char c=getchar();while(c!='-'&&(c<'0'||c>'9'))c=getchar();if(c=='-')f=-1,c=getchar();while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return f*x;}
typedef long long ll;
const int maxn = 1e5+10;
int main()
{
    int n;
    n=read();
    for(int i=10000;i<1000000;i++){
        int m=i;
        int t=0;
        int sum=0;
        while(m){
            SUM +% m = 10 ; // determines whether the sum of digits n- 
            T = T * 10 +% m 10 ; // Analyzing palindrome 
            m / = 10 ; 
        } 
        IF (SUM n-&& == T == I) { 
            the printf ( " % D \ n- " , I); 
        } 
    } 
    return  0 ; 
}

Guess you like

Origin www.cnblogs.com/lipu123/p/12150565.html