2 条题解

  • 1
    @ 2023-3-11 16:08:23
    #include<bits/stdc++.h>
    using namespace std;
    //输入保证正确
    //输出看仔细
    //所有情况都测
    //数组定义,保证正确
    int n ,s ;
    bool check (string s)
    {
    	for (int i = 0 ;i < s.size() ; i ++)
    		{
    		
    			if ( s [i] != s [ s.size() -1 -i])
    			{
    				return false;
    			}
    		}
    	return true;
    }
    string cmp (int n,int x)
    {
    	string s ="" ;
    	if (n == 0)
    		s = "0" ;
    	while (n != 0)
    	{
    		int g = n % x ;
    		if(g < 10)
    			s = char (g + 48 ) + s ;
    		else
    			s = char (g + 55 ) + s ;
    		n /= x ;
    	}
    	return s;
    }
    int main()
    {
    //	freopen("palsquare.in", "r", stdin);	
    //    freopen("palsquare.out", "w", stdout);
    	cin >> n >> s;
    	int t = 1 , x = s + 1;
    	while ( t <= n )
    	{
    		int ans = 0 ;
    		for ( int i = 2 ; i <= 10; i ++ )
    		{
    			string s = cmp ( x , i );
    			if ( check (s) == true )
    				ans ++ ;
    		}
    		if( ans >= 2 )
    		{
    			t ++ ;
    			cout << x << endl ;
    		}
    		x ++ ;
    	}
     	return 0;
    }
    ``
    
    • 0
      @ 2023-12-17 15:39:49
      #include<bits/stdc++.h>
      using namespace std;
      int n,m,i,cnt,tot;
      string s,t;
      void turn(int n,int p){
      	if(n==0)return;
      	turn(n/p,p);
      	s+=n%p+48;
      }
      int main(){
      	cin>>n>>m;i=m;
      	while(++i){
      		cnt=0;
      		for(int j=2;j<=10;j++){
      			s="";
      			turn(i,j);
      			t=s;
      			reverse(s.begin(),s.end());
      			if(s==t)cnt++;
      		}
      		if(cnt>=2){
      			cout<<i<<endl;
      			tot++;
      			if(tot==n)return 0;
      		}
      	}
      	return 0;
      }
      
      
      • 1

      信息

      ID
      228
      时间
      1000ms
      内存
      64MiB
      难度
      2
      标签
      递交数
      25
      已通过
      20
      上传者