Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdlib.h>
- #include <cmath>
- using namespace std;
- int main() {
- int a, b, c, d, g, i = 0, x1, x2, x3, y1, y2, y3;
- cin >> a;
- c = 0;
- g = 0;
- while(a) {
- b = a % 2;
- a /= 2;
- c = c * 10 + b;
- g++;
- }
- a = 0;
- if(g < 3) {
- cout << 0;
- exit(0);
- }
- for(d = 0; (d + 2) < g; d++) {
- x1 = c / pow(10, d);
- x2 = c / pow(10, d + 1);
- x3 = c / pow(10, d + 2);
- y1 = x1 % 10;
- y2 = x2 % 10;
- y3 = x3 % 10;
- if(y1 == 1 && y2 == 1 && y3 == 1) {
- ++i;
- }
- }
- cout << i;
- }
Add Comment
Please, Sign In to add comment