#include<stdio.h> #include<string.h> int N; char s1[10001]; char s2[10001]; void check() { int flag=0; int N2=N*N; int i=0; while(N) { s1[i++]="0123456789"[N%10]; N/=10; } i=0; while(N2) { s2[i++]="0123456789"[N2%10]; N2/=10; } for(int i=0;i<strlen(s1);++i) { if(s1[i]!=s2[i]) { flag=1; break; } } if(flag) { printf("No!\n"); } else printf("Yes!\n"); } int main(int argc, char *argv[]) { // freopen("1183.in", "r", stdin); while(~scanf("%d",&N)){ memset(s1,0,sizeof(s1)); memset(s2,0,sizeof(s2)); check(); } return 0; } /************************************************************** Problem: 1183 User: kirchhoff Language: C Result: Accepted Time:0 ms Memory:932 kb ****************************************************************/
原文地址:http://blog.csdn.net/wdkirchhoff/article/details/41944619