Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdio>
- #include <cstdlib>
- #include <cstring>
- #include <cctype>
- #include <cmath>
- #include <algorithm>
- #include <bitset>
- #include <vector>
- #include <stack>
- #include <queue>
- #include <set>
- #include <map>
- /*
- 1 2 3 4
- 3 1 4 2
- 4 3 2 1
- 2 4 1 3
- 1 2 3 4
- */
- int main() {
- int n, pos, cont;
- int metade;
- while(scanf("%d", &n) != EOF) {
- cont = 0;
- pos = 1;
- metade = n/2;
- do {
- if (pos <= metade) {
- pos *= 2;
- } else {
- pos = (n - ((n-pos+1) * 2)) + 1;
- }
- //printf("%d\n", pos);
- cont++;
- } while(pos != 1);
- printf("%d\n", cont);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement