zoukankan      html  css  js  c++  java
  • hdu 1032 水题也wrong 两次(于是乎更有刷水题的必要了)

    题意:

          清楚明了。

    注意:

           1.For any two numbers i and j you are to determine the maximum cycle length over all numbers between i and j

           并没有说i<j一定成立;

           2.The integers i and j must appear in the output in the same order in which they appeared in the input and should be followed by the maximum cycle    length (on the same line).

            i  和 j一定要输入的顺序与输出的顺序一样。

            于是就可以RE了!!!

    View Code
    #include<stdio.h>
    int main()
    {
        int n,m;
        int sum;
        int max;
        int i;
        int t,k;
        while(scanf("%d %d",&n,&m)!=EOF)
        {
            max=1;
            k=0;
            if(n>m){k=1;t=m;m=n;n=t;}
            for(int j=n;j<=m;j++)
            {
                i=j;
                sum=1;
                while(i!=1)
            {
                sum++;
                if(i%2==0)i/=2;
                else i=i*3+1;
            }
                if(sum>max)max=sum;
            }
            if(k==0)printf("%d %d %d\n",n,m,max);
            else printf("%d %d %d\n",m,n,max);
        }
        return 0;
    }
  • 相关阅读:
    opencv-识别手写数字
    opencv-图像遍历
    533. Lonely Pixel II
    531. Lonely Pixel I
    495. Teemo Attacking
    370. Range Addition
    487. Max Consecutive Ones II
    485. Max Consecutive Ones
    414. Third Maximum Number
    90. Subsets II
  • 原文地址:https://www.cnblogs.com/XDJjy/p/2999273.html
Copyright © 2011-2022 走看看