2 条题解

  • 0
    @ 2025-9-27 15:23:47
    #include<bits/stdc++.h>
    using namespace std;
    int main(){	//区间里的哈沙德数
    	int a,b;
    	cin>>a>>b;
    	for(int i=a;i<=b;i++){
    		int j=i;
    		if(i<=9 or i==1000){
    			cout<<i<<" ";
    		}else if(i<=99){
    			if(i%(i/10+i%10)==0){
    				cout<<i<<" ";
    			}
    		}else if(i<=999){
    			if(i%(i/100+i/10%10+i%10)==0)
    				cout<<i<<" ";
    		}			
    	} 
    	return 0;
    }
    
    • 0
      @ 2024-8-10 11:13:19
      #include<bits/stdc++.h>
      using namespace std;
      int main(){  // CL12 区间里的哈沙德数
      	long long a,b; bool c=true;
      	cin>>a>>b;
      	for(long long i=a;i<=b;i++){
      		long long j=i;
      		long long sum=0;
      		while(j){
      			sum+=j%10;
      			j/=10;
      		}
      		if(i%sum==0){
      		  c=false;
      			cout<<i<<" ";
      		}
      	}
      	if(c) cout<<-1;
      	return 0;
      }
      
      
      • 1

      信息

      ID
      1745
      时间
      1000ms
      内存
      256MiB
      难度
      10
      标签
      (无)
      递交数
      1
      已通过
      1
      上传者