2 条题解

  • 0
    @ 2025-3-30 20:10:57
    #include<stdio.h>
    int main()
    {
        int n,sum=0;
        scanf("%d",&n);
        while(n!=1)
        {
            if(n%2==0)
            {
                n/=2;
            }
            else
            {
                n=n*3+1;
            }
            sum++;
        }
        printf("%d",sum);
        return 0;
    }
    ```
    
    
    ```
    • 0
      @ 2024-9-21 0:07:47
      #include <stdio.h>
      
      int main()
      {
          int n, count = 0;
          scanf("%d", &n);
          while (n != 1)
          {
              if (n % 2)
              {
                  n = n * 3 + 1;
              }
              else
              {
                  n /= 2;
              }
              count++;
          }
          printf("%d", count);
          return 0;
      }
      
      • 1

      信息

      ID
      129
      时间
      1000ms
      内存
      256MiB
      难度
      9
      标签
      递交数
      11
      已通过
      5
      上传者