题解 | #守形数#

守形数

https://www.nowcoder.com/practice/99e403f8342b4d0e82f1c1395ba62d7b

#include <bits/stdc++.h>
using namespace std;

bool isShou(int n){
	string s1=to_string(n);
	string s2=to_string(n*n);
	int len1=s1.size();
	int len2=s2.size();
	for(int i=0;i<len1;i++){
		if(s1[len1-1-i]!=s2[len2-1-i]){
			return false;
		}
	}
	return true;
}
int main(){
	int n;
	while(cin>>n){
		if(isShou(n)){
			cout<<"Yes!"<<endl;
		}else{
			cout<<"No!"<<endl;
		}
	}
	return 0;
}

全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务