andre_joy

导航

hdu 1391

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

题意:按图输出图上数字。

mark:模仿图形里面数字变换特性。

代码:

#include <stdio.h>

int a[5010][2];

int main()
{
    int n,x,y,m;
    int i;
    a[0][0] = 0;
    a[1][1] = 1;
    i = m = 2;
    while(i < 5001)
    {
        a[i++][0] = m++;
        a[i--][0] = m++;
        a[i++][1] = m++;
        a[i++][1] = m++;
    }
    scanf("%d", &n);
    while(n-- && scanf("%d%d", &x, &y))
    {
        if(!(x == y || x-y == 2))
        {
            puts("No Number");
            continue;
        }
        printf("%d\n", x == y ? a[x][1] : a[x][0]);
    }
    return 0;
}

posted on 2012-07-05 23:48  andre_joy  阅读(111)  评论(0编辑  收藏  举报