-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1011.cpp
More file actions
43 lines (40 loc) · 796 Bytes
/
1011.cpp
File metadata and controls
43 lines (40 loc) · 796 Bytes
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
37
38
39
40
41
42
43
#include <iostream>
using namespace std;
int arr[15][15];
int main(int argc, char** argv)
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n,a,b,c,ans,flag = 0,cnt = 0,rc = 0,mid;
cin>>n;
for (int i = 0; i < n; ++i)
{
cin>>a>>b;
ans = (b-a)/2;
mid = b-a;
c = 0;
while(c<mid)
{
rc++;
if(c>=ans&&flag ==0)
{
mid = b-a-c;
c=0;
cnt=0;
flag =1;
}
cnt++;
c = c + cnt;
}
if(b-a==1||b-a==2||b-a==3)cout<<b-a<<"\n";
else
{
cout<<rc<<"\n";
}
cnt = 0;
flag = 0;
rc = 0;
}
return 0;
}