public class Solution {
private static int cnt = 0;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int m = sc.nextInt();
for(int i = 0; i <= m; i ++) {
helper(i);
}
System.out.println(cnt);
}
public static void helper(int n) {
if(n < 3) {
cnt ++;
return ;
}
int pre = n & 1;
n >>= 1;
while(n != 0) {
if(pre == 1 && (n & 1) == 1) {
return ;
}
pre = n & 1;
n >>= 1;
}
cnt ++;
}
}
1111111111111111111111111111111
最新推荐文章于 2023-01-15 19:34:25 发布