# USACO Dual Palindromes 题解

```/*
ID: bbsunch2
PROG: dualpal
LANG: C++
*/
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <stdlib.h>

using namespace std;

string changeBase(int formerNum, int baseNum)
{
string latterNumString;
while(formerNum)
{
char c;
int num = formerNum % baseNum;
if(num < 10)
{
c = (char)(num+48);
}else
{
c = (char)(num+55);
}
latterNumString.insert(latterNumString.begin(),c);
formerNum =  (int)(formerNum / baseNum);
}
return latterNumString;
}

bool checkPals(string input)
{
bool pals = true;
int inputLength = input.length();
int halfLength = (int)(inputLength/2);
for(int i = 0; i < halfLength; i++)
{
int k = inputLength - i - 1;
if(input[i] != input[k])
{
pals = false;
break;
}
}
return pals;
}

int main()
{
ofstream fout ("dualpal.out");
ifstream fin ("dualpal.in");

int N = 0;
int S = 0;
fin >> N >> S;
int printNum = 0;

while(printNum < N)
{
S ++;
int palsNum = 0;
bool dualpal = false;
for(int baseNum = 2; baseNum <= 10; baseNum++)
{
string result = changeBase(S, baseNum);
bool pals = checkPals(result);
if(pals)
{
palsNum ++;
if(palsNum >= 2)
{
dualpal = true;
break;
}
}
}
if(dualpal)
{
fout << S << endl;
printNum ++;
}
}
return 0;
}
```

USACO Dual Palindromes 题解

• 0

开心

• 0

板砖

• 0

感动

• 0

有用

• 0

疑问

• 0

难过

• 0

无聊

• 0

震惊

【问题描述】 据说如果你给无限只母牛和无限台巨型便携式电脑(有非常大的键盘),那么母牛们会制造出

select 11+22+22 ; select 11+22+22 from dual; select ab+ba; select ab+ba from dual; 我个人理解
A system switches between non-secure and secure modes by making processes, applications, and
In multiple-output power supplies in which a single supply powers circuitry of vastly differe

Batteries are the typical power sources for portable-system applications, and it is not unusu
This Design Idea stems from the limited availability of IC voltage regulators that can meet k
The AD736 true-rms-to-dcconverter is useful for many applications that require precise calcul