/*********************************
* 日期:2013-2-7
* 作者:SJF0115
* 题号: 九度OJ 题目1136:Number Steps
* 来源:http://ac.jobdu.com/problem.php?pid=1136
* 结果:AC
* 来源:2008年北京大学软件所计算机研究生机试真题
* 总结:
**********************************/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
int i,j,n;
int x,y;
//freopen("C:\\Users\\SJF\\Desktop\\acm.txt","r",stdin);
while(scanf("%d\n",&n) != EOF)
{
for(i = 0;i < n;i++){
scanf("%d %d",&x,&y);
if(x == y){
//偶数
if(x % 2 == 0){
printf("%d\n",2 * y);
}
//奇数
else{
printf("%d\n",2 * y - 1);
}
}
else if(x == 2 + y){
//偶数
if(x % 2 == 0){
printf("%d\n",2 * y + 2);
}
//奇数
else{
printf("%d\n",2 * y + 1);
}
}
else{
printf("No Number\n");
}
}
}
return 0;
}
九度OJ 题目1136:Number Steps
最新推荐文章于 2017-04-08 10:42:32 发布
