HDU 1391 Number Steps

http://acm.hdu.edu.cn/showproblem.php?pid=1391

View Code
#include <stdio.h>
#include <string.h>
int main()
{
    int t;
    int x,y;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d%d",&x,&y);
        if(x!=y&&x!=y+2)
            puts("No Number");
        else
        {
            if(y%2)
                if(x>y)
                    printf("%d\n",2*y+1);
                else
                    printf("%d\n",2*y-1);
            else
                if(x>y)
                    printf("%d\n",2*y+2);
                else
                    printf("%d\n",2*y);
        }
    }
    return 0;
} 
原文地址:https://www.cnblogs.com/xiaohongmao/p/2471210.html