3 solutions

  • 0
    @ 2025-7-15 10:04:08
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
    	int l,r,all=0;
    	cin>>l>>r;
    	for(int i=l;i<=r;i++)
    	{
    		int a[15]={};
    		int t=i;
    		while(t)
    		{
    			int ge=t%10;
    			a[ge]++; 
    			t/=10;
    		}
    		t=i;
    		int cnt=0;
    		while(t)
    		{
    		    int ge=t%10;
    		    if(ge!=a[ge])
    		    {
    		    	cnt++;
    			}
    			t/=10;
    		}
    		
    		if(cnt==0)
    		{
    			all+=i;
    		}
    	}
    	cout<<all;
    	return 0;
    
    • -1
      @ 2025-8-22 15:50:35
      #include<bits/stdc++.h>
      using namespace std;
      int main()
      {
      	int l,r,all=0;
      	cin>>l>>r;
      	for(int i=l;i<=r;i++)
      	{
      		int a[15]={};
      		int t=i;
      		while(t)
      		{
      			int ge=t%10;
      			a[ge]++; 
      			t/=10;
      		}
      		t=i;
      		int cnt=0;
      		while(t)
      		{
      		    int ge=t%10;
      		    if(ge!=a[ge])
      		    {
      		    	cnt++;
      			}
      			t/=10;
      		}
      		
      		if(cnt==0)
      		{
      			all+=i;
      		}
      	}
      	cout<<all;
      	return 0;
      
      
      • -2
        @ 2025-8-13 15:51:22

        看到这个题解的人这辈子有了!

        • @ 2025-8-13 16:03:59
          #include<bits/stdc++.h>
          using namespace std;
          int l,r;
          int main(){
          	int sum=0;
          	cin>>l>>r;
          	for(int i=l;i<=r;i++){
          		int a[15]={};
          		int t=i;
          		while(t){
          			int ge=t%10;
          			a[ge]++;
          			t/=10;
          		}
          		t=i;
          		int cnt=0;
          		while(t){
          			int ge=t%10;
          			if(ge!=a[ge]){
          				cnt++;
          			}
          			t/=10;
          		}
          		if(cnt==0){
          			sum+=i; 
          		}
          	}
          	cout<<sum;	
          	
          	return 0;
          }
          
      • 1

      Information

      ID
      2864
      Time
      1000ms
      Memory
      64MiB
      Difficulty
      5
      Tags
      # Submissions
      37
      Accepted
      15
      Uploaded By