文章

166

粉丝

68

获赞

859

访问

63.9k

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

  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. bool judge(int x){
  4. int y=x*x;
  5. int size=1;
  6. int t=x;
  7. while(x!=0){
  8. size*=10;
  9. x/=10;
  10. }
  11. y%=size;
  12. return t==y;
  13. }
  14. int main() {
  15. int x;
  16. while(cin>>x){
  17. if(judge(x))cout<<"Yes!"<<endl;
  18. else cout<<"No!"<<endl;
  19. }
  20. }

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发