Create 5881_chen9510.cpp

From http://www.cnblogs.com/chen9510/p/5879710.html
pull/45/head
Kirigaya Kazuto 2016-09-17 22:00:38 +08:00 committed by GitHub
parent 7d75c7abe9
commit 2d36c59bba
1 changed files with 37 additions and 0 deletions

37
HDOJ/5881_chen9510.cpp Normal file
View File

@ -0,0 +1,37 @@
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <queue>
#include <cmath>
#include <string.h>
using namespace std;
int main()
{
long long L,R;
while(scanf("%lld%lld",&L,&R)!=EOF)
{
if(L==R)
{
if(R<=1) puts("0");
else if(R==2) puts("1");
else puts("2");
continue;
}
if(L==0)
{
if(R==1) puts("0");
else if(R==2) puts("1");
else printf("%lld\n",(R+1)/2);
}
else
{
if(L==1&&R==2) puts("1");
else{
if(L+2>=R-1) puts("2");
else printf("%lld\n",(R-L+2)/2);
}
}
}
return 0;
}