www.dotcpp.com/oj/problem3…
#include<bits/stdc++.h>
using namespace std;
bool flag;
int cnt;
bool solve(int x)
{
flag = false;
int index= 1;
int temp = x;
while (temp)
{
int t = temp % 10;
if ((index % 2 == 1) &&( t % 2 == 1))
{
flag = true;
}
else if ((index % 2 == 0) &&( t % 2 == 0))
{
flag = true;
}
else
{
flag = false;
break;
}
temp /= 10;
index++;
}
if (flag)
{
return true;
}
return false;
}
int main()
{
cin.tie(nullptr)->sync_with_stdio(false);
int n; cin >> n;
for (int i = 1; i <= n; i++)
{
if(solve(i))cnt++;
}
cout << cnt << endl;
return 0;
}
