追踪1号队员,取他回到原来位置需要的次数

#include<stdio.h>
int main(){
    int T,t,n,ans,x;
    scanf("%d",&T);
    for(t=1;t<=T;t++){
        scanf("%d",&n);
        ans=x=1;
        while(x!=n+1){
            if(x>n)
                x=(x-n)*2-1;
            else
                x*=2;
            ans++;
        }
        printf("Case #%d:\n%d\n",t,ans);
    }
    
    return 0;
}

 

相关文章:

  • 2021-10-31
  • 2021-08-06
  • 2021-08-05
  • 2021-08-03
  • 2021-12-08
  • 2021-10-16
  • 2021-12-29
  • 2021-09-04
猜你喜欢
  • 2021-05-19
  • 2021-11-04
  • 2021-07-21
  • 2022-02-19
  • 2021-10-28
  • 2021-05-24
  • 2021-10-21
相关资源
相似解决方案