标签:style blog color os io ar for div log
这个居然还一下就通过了,呵呵:
/* ID: qq104801 LANG: C++ TASK: palsquare */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <assert.h> /* for debug only:counter */ void debug_dummy(void) { return; } int base; char x[64]; char num[]={‘0‘,‘1‘,‘2‘,‘3‘,‘4‘,‘5‘,‘6‘,‘7‘,‘8‘,‘9‘, ‘A‘,‘B‘,‘C‘,‘D‘,‘E‘,‘F‘,‘G‘,‘H‘,‘I‘,‘J‘}; void xnum(int a,int b) { int i=0; int c=a; while(c!=0) { x[i]=num[c%b]; c=c/b; i++; } x[i]=‘\0‘; //printf("%s len:%d\n",x,strlen(x)); } int ispalindromes(char* s) { int l=strlen(s); int f=1; for(int i=0;i<(l/2);i++) { if(s[i]!=s[l-i-1]) { f=0; break; } } return f; } void test(FILE* f) { int bb; for(int i=1;i<301;i++) { bb=i*i; xnum(bb,base); if (ispalindromes(x)) fprintf(f,"%d %d\n",i,bb); } } main () { FILE *fin = fopen ("palsquare.in", "r"); FILE *fout = fopen ("palsquare.out", "w"); fscanf(fin,"%d",&base); //printf("%d\n",base); test(fout); fclose(fin); fclose(fout); exit (0); }
测试用例:
USER: ll tom [qq104801] TASK: namenum LANG: C++ Compiling... Compile: OK Executing... Test 1: TEST OK [0.005 secs, 3556 KB] Test 2: TEST OK [0.005 secs, 3556 KB] Test 3: TEST OK [0.005 secs, 3556 KB] Test 4: TEST OK [0.014 secs, 3556 KB] Test 5: TEST OK [0.011 secs, 3556 KB] Test 6: TEST OK [0.011 secs, 3556 KB] Test 7: TEST OK [0.008 secs, 3556 KB] Test 8: TEST OK [0.008 secs, 3556 KB] Test 9: TEST OK [0.011 secs, 3556 KB] Test 10: TEST OK [0.008 secs, 3556 KB] Test 11: TEST OK [0.019 secs, 3556 KB] Test 12: TEST OK [0.016 secs, 3556 KB] Test 13: TEST OK [0.008 secs, 3556 KB] Test 14: TEST OK [0.008 secs, 3556 KB] Test 15: TEST OK [0.014 secs, 3556 KB] All tests OK. Your program (‘namenum‘) produced all correct answers! This is your submission #7 for this problem. Congratulations! Here are the test data inputs: ------- test 1 ---- 4734 ------- test 2 ---- 234643 ------- test 3 ---- 5747867437 ------- test 4 ---- 223 ------- test 5 ---- 532 ------- test 6 ---- 546 ------- test 7 ---- 53662 ------- test 8 ---- 5455426 ------- test 9 ---- 26678268463 ------- test 10 ---- 463373633623 ------- test 11 ---- 282742662 ------- test 12 ---- 463373633623 ------- test 13 ---- 2336 ------- test 14 ---- 5264 ------- test 15 ---- 426 Keep up the good work! Thanks for your submission!
说明理解了题意。
标签:style blog color os io ar for div log
原文地址:http://www.cnblogs.com/dpblue/p/3946964.html