| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
纯枚举就能过啊,献上代码#include <iostream>
using namespace std;
int main ()
{
int a,b,k,i;
cin>>k;
for (i=0;i<k;i++)
{
cin>>a>>b;
if (a==b&&a%2==0)
{
cout<<a*2<<endl;
continue;
}
if (a==b&&a%2==1)
{
cout<<(a-1)*2+1<<endl;
continue;
}
if (a==(b+2)&&a%2==0)
{
cout<<(a-1)*2<<endl;
continue;
}
if (a==(b+2)&&a%2==1)
{
cout<<(a-2)*2+1<<endl;
continue;
}
if (a!=b+2&&a!=b)
{
cout<<"No Number"<<endl;
continue;
}
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator