题目描述:
计算大于正整数1600000的最小双基回文数
双基回文数:一个数的n进制(2≤n≤10)是回文数的至少存在2种,则这个数是双基回文数,代码:
using System;
using System.Collections.Generic;
namespace a1
{
class Program
{
public static bool Judge(string s){
int i,l=s.Length;
char[] ch=s.ToCharArray();
for(i=0;i<=l/2;i++){
if(ch[i]!=ch[l-1-i]) break;
}
if(i*2>=l) return true;
else return false;
}
public static int judge(int n){
int s=0;
for(int i=2;i<=10;i++){
string str="";
int k=n;
while(k!=0){
str+=k%i;
k=k/i;
}
if(Judge(str)) s++;
}
return s;
}
public static void Main(string[] args)
{
int i;
for(i=1600000;;i++){
if(judge(i)>=2) break;
}
Console.WriteLine(i);
Console.ReadLine();
}
}
}
提交CTF{1632995},通过!