Usaco 1.2.4 palindromic squares

Source: Internet
Author: User

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 ;}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.