forked from ShivamDubey7/Competitive-Programming-Algos
-
Notifications
You must be signed in to change notification settings - Fork 315
/
Ceiling sum.cpp
36 lines (31 loc) · 808 Bytes
/
Ceiling sum.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include<bits/stdc++.h>
using namespace std ;
#define ff first
#define ss second
#define ull unsigned long long
#define mod 1000000007
#define inf 1e18
#define w(x) int x;cin>>x;while(x--)
#define f(x,y) for( x=0;x<y;x++)
int main(){
w(t){
double a,b, s1,s2;
long long x;
cin>>a>>b;
s1=ceil((b-(a-1))/2)+ceil(((a-1)-a)/2);
s2=ceil((b-(a+1))/2)+ceil(((a+1)-a)/2);
// cout<<"i is "<<i<<" ";
// cout<<"s1 is"<<s1<<"s2 is"<<s2<<endl;
// maximum=ceil(s1)+ceil(s2);
if(a==b){
x=0;
}
else if(a>b){
x=s1;
}
else{
x=s2;
} cout<<x<<endl;
}
return 0;
}