http://acm.pku.edu.cn/JudgeOnline/problem?id=1663经过分析,得到以下规律
n x , y
n%4==0 n/2,n/2
n%4==1 (n+1)/2,(n+1)/2
n%4==2 (n+2)/2,(n+2)/2-2
n%4==3 (n+1)/2+1,(n+1)/2-1
一次ac
Source
Problem: 1663 User: lnmm
Memory: 72K Time: 15MS
Language: C++ Result: Accepted
#include"stdio.h"
void main()
{
int T;
int m;
int x,y;
int temp;
scanf("%d",&T);
{
for(m=0;m<T;m++)
{
temp=-1;
scanf("%d%d",&x,&y);
if(x==y)
{
if(x*2%4==0)temp=x*2;
if((x*2-1)%4==1)temp=x*2-1;
}
else
{
if((x==y+2)&&(x*2-2)%4==2)temp=x*2-2;
if((x==y+2)&&((x-1)*2-1)%4==3)temp=(x-1)*2-1;
}
if(temp==-1)printf("No Number\n");
else printf("%d\n",temp);
}
}
}