📄 dualpal.cpp
字号:
/*
ID: chenkai4
PROG: dualpal
LANG: C++
*/
#include<iostream>
#include<fstream>
using namespace std;
ifstream in("dualpal.in");
ofstream out("dualpal.out");
#define MAXARRAY 10000
int N,S;
struct _int
{
int l,b[MAXARRAY];
int base;
_int(int n=0,int Base =10)
{
base = Base;
l=0;memset(b,0,sizeof(b));
while(n)
{
b[l++]=n%base;
n/=base;
if(b[l])l++;
}
}
_int& carry()
{
for(int a=0;a<l;a++)
{
b[a+1]+=b[a]/base;
b[a]%=base;
if(b[l])l++;
}
return *this;
}
};
bool pan(_int how)
{
for(int a=0;a<=(how.l-1)/2;a++)
if(how.b[a]!=how.b[how.l-1-a])
return false;
return true;
}
bool isPalindrome(int which)
{
int count=0;
for(int a=2;a<=10;a++)
{
_int thisone(which,a);
if(pan(thisone))
count++;
}
if(count>=2)
return true;
else
return false;
}
int main()
{
in>>N>>S;
int count=0;
while(count<N)
{
S++;
if(isPalindrome(S))
{out<<S<<endl;count++;}
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -