HDU1210 Eddy's 洗牌问题

题目链接

分析:

发现只要模拟1的变化就很水了。

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(){
    int n, t, cnt;
    while(scanf("%d", &n) == 1){
        t = 2;
        cnt = 1;
        while(t != 1){
            if(t <= n) t *= 2;
            else t=(t-n-1)*2+1;
            cnt++;
        }
        printf("%d\n", cnt);
    }

    return 0;
}
原文地址:https://www.cnblogs.com/tanhehe/p/3000007.html