USACO 1.2 Dual Palindromes (retrieval, hexadecimal conversion)
Cool nonsense, post code:
/* ID: twd30651 PROG: dualpal LANG: C ++ */# include
# Include
# Include
# Include
Using namespace std; char s [1, 100]; int N, S; void gs (int num, int BASE) {int index = 0; while (num/BASE) {s [index ++] = "0123456789 ABCDEF" [num % BASE]; // It is easy to understand and easy to understand, A 17-byte String constant num = num/BASE is wasted;} s [index ++] = "0123456789 ABCDEF" [num % BASE]; s [index] = '\ 0';} bool isPalindromes () {size_t len = strlen (s ); if (s [0] = '0' & s [len-1] = '0') return false; for (size_t I = 0; I <= len/2; ++ I) {if (s [I]! = S [len-i-1]) return false;} return true;} int main (int argc, char * argv []) {freopen ("dualpal. in "," r ", stdin); freopen (" dualpal. out "," w ", stdout); scanf (" % d ", & N, & S); int count = 0; int fn = 0; for (int I = S + 1; ++ I) {fn = 0; for (int j = 2; j <= 10; ++ j) {if (fn <2) {memset (s, 0, sizeof (s); gs (I, j); if (isPalindromes () {fn ++; if (fn = 2) {printf ("% d \ n", I); count ++; break ;}}} if (count = N) break ;} return 0 ;}