P1362我是菜鸡只有20分
  • 板块P1362 兔子数
  • 楼主hiYE_ame
  • 当前回复1
  • 已保存回复1
  • 发布时间2023/12/2 21:33
  • 上次更新2023/12/2 23:36:55
查看原帖
P1362我是菜鸡只有20分
766454
hiYE_ame楼主2023/12/2 21:33
#include<iostream>
using namespace std;
int S(int x){
    int ans=0;
    int y=x;
    while(y>=1){
        ans+=y%10;
        y/=10;
    }
    return ans;
}
int main(){
    int l,r,cnt=0;
    cin>>l>>r;
    for(int i=l;i<=r;i++){
        if(S(i*i)==S(i)*S(i)){
            cnt++;
        }
    }
    cout<<cnt;
    return 0;
}
2023/12/2 21:33
加载中...