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; }