文章

119

粉丝

68

获赞

90

访问

19.9k

头像
守形数 题解:长度判定用求模方法计算
P1406 华中科技大学
发布于2025年2月21日 15:36
阅读数 22

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

bool judge(int x){
    int y=x*x;
    int size=1;
    int t=x;
    while(x!=0){
        size*=10;
        x/=10;
    }
    y%=size;
    return t==y;
}

int main() {
	int x;
	while(cin>>x){
	    if(judge(x))cout<<"Yes!"<<endl;
	    else cout<<"No!"<<endl;
	}

}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发