1 条题解

  • 0
    @ 2025-8-25 18:03:38
    #include<bits/stdc++.h>
    #define int long long
    using namespace std;
    int sb(int x){
    	int ans=0;
    	while(x>0) ans+=x%10,x/=10;
    	return ans;
    }
    bool check(int x){return sb(x*x)==sb(x)*sb(x);}
    int l,r,sum=0,a[]={};
    signed main(){
    	std::ios_base::sync_with_stdio(0);
    	cout.tie(0),cin.tie(0);
    	cin >>l>>r;
    	for(int a0=0;a0<=3;a0++){
    	for(int a1=0;a1<=3;a1++){
    	for(int a2=0;a2<=3;a2++){
    	for(int a3=0;a3<=3;a3++){
    	for(int a4=0;a4<=3;a4++){
    	for(int a5=0;a5<=3;a5++){
    	for(int a6=0;a6<=3;a6++){
    	for(int a7=0;a7<=3;a7++){
    	for(int a8=0;a8<=3;a8++){
    	for(int a9=0;a9<=3;a9++){
    		int num=a0*1000000000+a1*100000000+a2*10000000+a3*1000000+a4*100000+a5*10000+a6*1000+a7*100+a8*10+a9;
    		if(num>=l && num<=r){
    			if(check(num)==1) sum++;
    		}
    	}}}}}}}}}}
    	cout<<sum;
    	return 0;
    }
    
    
    • 1

    信息

    ID
    3328
    时间
    1000ms
    内存
    256MiB
    难度
    3
    标签
    (无)
    递交数
    48
    已通过
    25
    上传者