From 2d36c59bbaf6666fb23f6e1aba0c7ee60c3e963c Mon Sep 17 00:00:00 2001 From: Kirito <1362050620@qq.com> Date: Sat, 17 Sep 2016 22:00:38 +0800 Subject: [PATCH] Create 5881_chen9510.cpp From http://www.cnblogs.com/chen9510/p/5879710.html --- HDOJ/5881_chen9510.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 HDOJ/5881_chen9510.cpp diff --git a/HDOJ/5881_chen9510.cpp b/HDOJ/5881_chen9510.cpp new file mode 100644 index 0000000..6e0f6ef --- /dev/null +++ b/HDOJ/5881_chen9510.cpp @@ -0,0 +1,37 @@ +#include +#include +#include +#include +#include +#include +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; +}