let's start Code

Dual Palindromes

Dual Palindromes

#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define MAX 10005
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
/*
ID: hasanma1
TASK: dualpal
LANG: C++
*/
char value[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
string Base(int n, int base)
{
string t;
while(n != 0)
{
t = value[n % base] + t;
n /= base;
}
// cerr << t << endl;
return t;
}
int main()
{
FASTIO
/*
//double start_time = clock();
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
freopen("error.txt", "w", stderr);
#endif
//*/
///*
ofstream cout ("dualpal.out");
ifstream cin ("dualpal.in");
//*/
int n, S;
cin >> n >> S;
//cerr << base<<endl;
//cerr << i+i << endl;
int res = 0;
for(int j = S + 1; ; j++)
{
int cnt = 0;
for(int k = 2; k <= 10; k++)
{
string N = Base(j, k);
//string sq = Base(j * j, k);
string _new = N;
reverse(_new.begin(), _new.end());
if(N == _new)
{
cnt++;
//cout << N << " " << sq << "\n";
}
if(cnt > 1)
{
cout << j << endl;
res++;
break;
}
}
if(res >= n)break;
}
//double end_time = clock();
//printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);
return 0;
}
view raw dualpal.cpp hosted with ❤ by GitHub
Share:

Related Posts:

No comments:

Post a Comment

About

let's start CODE

Popular Posts