Usaco 1.2.4 palindromic squares
Blind beat + 1! For cervical spine + 1!
Question :...... Note that the question is 1 ~ 300 the square of these numbers is converted into the corresponding hexadecimal number,! The first number in each row is represented by the required input !!!!!!!! I did not understand the test case at the beginning.
Details +Code:
/* ID: 15257142 LANG: C task: palsquare */# include <stdio. h> # include <string. h> # include <math. h> int N; int trans (INT num, char B [20]) {int K, G; k =-1; while (Num> 0) {k ++; G = num % N; If (G> 9) B [k] = G-10 + 'a'; elseb [k] = g-0 + '0 '; num = num/N;} B [k + 1] = '\ 0'; return K;} int transnum (INT num, int N, char E [20]) {int K; k =-1; while (Num> 0) {k ++; If (Num % N> 9) E [k] = num % N-10 + 'a'; elsee [k] = num % N + '0'; num = num/N;} return K;} int Mai N () {// It's too long. It won't be like this at the beginning if the question is clear ...... Freopen ("palsquare. in "," r ", stdin); freopen (" palsquare. out "," W ", stdout); int I, J, K, G, T, F; char C [20], d [20], B [20], E [20]; scanf ("% d", & N); for (I = 1; I <= 300; I ++) {k = I * I; G = trans (K, B); For (j = 0; j <= g/2; j ++) C [J] = B [J]; c [J] = '\ 0'; If (G % 2 = 1) F = g/2 + 1; elsef = g/2; for (j = g; j> = f; j --) d [G-J] = B [J]; d [G-J] = '\ 0'; If (strcmp (c, d) = 0) {k = transnum (I, n, e); For (j = K; j> = 0; j --) printf ("% C ", E [J]); printf (""); printf ("% s \ n", B) ;}} fclose (stdin); fclose (stdout); Return 0 ;}