mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
Create 5881_chen9510.cpp
From http://www.cnblogs.com/chen9510/p/5879710.html
This commit is contained in:
parent
7d75c7abe9
commit
2d36c59bba
37
HDOJ/5881_chen9510.cpp
Normal file
37
HDOJ/5881_chen9510.cpp
Normal 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user