2 条题解

  • 0
    @ 2025-10-8 16:53:43
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        int n; 
        while(scanf("%d",&n)!=EOF)
        {
            int x=1,s=0;//只需要关注牌面为1的牌的位置 
            do
            {
                if(x>n)x=((x-n)<<1)-1;
                else x<<=1;
                s++;
            }while(x!=1);
            printf("%d\n",s);
        }
        return 0;
    }
    
    • 0
      @ 2025-10-8 16:53:37
      #include<bits/stdc++.h>
      using namespace std;
      int main()
      {
      	int n; 
          while(scanf("%d",&n)!=EOF)
          {
              int x=1,s=0;//只需要关注牌面为1的牌的位置 
              do
              {
                  if(x>n)x=((x-n)<<1)-1;
                  else x<<=1;
                  s++;
              }while(x!=1);
              printf("%d\n",s);
          }
          return 0;
      }
      • 1

      信息

      ID
      826
      时间
      1000ms
      内存
      128MiB
      难度
      2
      标签
      递交数
      53
      已通过
      33
      上传者