#include <iostream>
using namespace std;
int sum( int n ){
int k = 0;
int t = n;
while ( t > 0 )
{
if ( ( t % 10 ) % 2 == 0 )
k++;
t /= 10;
}
return k;
int main()
int M,S,p;
cin >> M;
S = 0;
for ( int i = 1; i < M; i++ ){
p = sum(i);
if ( p == 0 ) {
S = S + i;
cout << S;
return 0;
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
#include <iostream>
using namespace std;
int sum( int n ){
int k = 0;
int t = n;
while ( t > 0 )
{
if ( ( t % 10 ) % 2 == 0 )
k++;
t /= 10;
}
return k;
}
int main()
{
int M,S,p;
cin >> M;
S = 0;
for ( int i = 1; i < M; i++ ){
p = sum(i);
if ( p == 0 ) {
S = S + i;
}
}
cout << S;
return 0;
}