Initial commit
This commit is contained in:
30
15lanqiao/test3.cpp
Normal file
30
15lanqiao/test3.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
bool check(int n){
|
||||
int b = 1; //数位
|
||||
while(n){
|
||||
if(b % 2){ // 奇数位
|
||||
if(!(n % 10 % 2)) return false;
|
||||
}else{ // 偶数位
|
||||
if(n % 10 % 2) return false;
|
||||
}
|
||||
n /= 10;
|
||||
b++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int main() {
|
||||
int n; cin >>n;
|
||||
int ans = 0;
|
||||
for(int i = 1; i <= n; i++){
|
||||
if(i % 10 % 2 == 0) continue;
|
||||
if(check(i)) ans++;
|
||||
}
|
||||
cout << ans << endl;
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
一个整数如果按从低位到高位的顺序,奇数位为奇数,偶数位为偶数,则该数为好数
|
||||
24 -> 7, 2024 -> 150
|
||||
*/
|
||||
Reference in New Issue
Block a user