Advertisement
a53

echilibrat_ab

a53
Dec 5th, 2019
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. bool echilibrat(int n)
  5. {
  6. int cp=0,ci=0;
  7. while(n)
  8. {
  9. if(n%10%2)
  10. ++ci;
  11. else
  12. ++cp;
  13. n/=10;
  14. }
  15. if((ci+cp)%2==0&&ci==cp)
  16. return true;
  17. return false;
  18. }
  19.  
  20. int main()
  21. {
  22. int a,b;
  23. cin>>a>>b;
  24. unsigned long long int s=0;
  25. for(int i=a;i<=b;++i)
  26. if(echilibrat(i))
  27. s+=i;
  28. cout<<s;
  29. return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement