eolymp
Problems

The minimal sum of digits

published at 6/14/22, 10:53:09 am

include <iostream>

include<map>

using namespace std;

int main() { long m,i,mini=100,n,ans=0; cin>>m>>n; for(i=m;i<=n;i++) { long ic=i,sum=0; while(ic!=0) { sum+=ic%10; ic/=10; } if(sum<mini) mini=sum; if(mini==1) break; } for(i=m;i<=n;i++) { long sum=0,ic=i; while(ic!=0) { sum+=ic%10; ic/=10; } if(sum==mini) { ans++; } } cout<<ans; }