全部TLE!求助!
查看原帖
全部TLE!求助!
1032587
Alice_zhang楼主2024/4/13 21:12
#include <iostream>
#include <string>
using namespace std;

bool hui_wen(string s)
{
    for(int i = 0; i <= (s.size() - 1) / 2 + 1; i++)
    {
        if(s[i] != s[s.size() - i])return false;
    }
    return true;
}

string Dtom(int n, int x)
{
    string s = "";
    do
    {
        int a = n % x;
        s = char(a - '0') + s;
        n /= x;
    }while(n != 0);
    return 0;
}

int main()
{
    
    int n, m;
    cin >> n >> m;
    int i = m + 1;
    int cnt = 0;
    while(cnt != n)
    {
        int t = 0;
        for(int j = 2; j <= 10; j++)
        {
            if(hui_wen(Dtom(i, j)))
            {
                 t++;
            }
        }
        if(t >= 2)
        {
            cout << i << endl;
            cnt++;
        }
        i++;
    }
    return 0;
}

结果就是很悲伤的全部TLE

2024/4/13 21:12
加载中...