-
Notifications
You must be signed in to change notification settings - Fork 0
/
math_interesting.cpp
62 lines (59 loc) · 1018 Bytes
/
math_interesting.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
ll str,in,ex;
cin>>str>>in>>ex;
ll t=ex,t1=0;
//p=min(c1,c2);
if(str+ex<=in)
{
cout<<0<<endl;
}
else if(str>in+ex)
{
cout<<ex+1<<endl;
}
else
{
ll ans=str - in + ex+1 ;
cout<<(ans/2)<<endl;
}
}
}
#include<bits/stdc++.h>
using namespace std;
#define cool ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int main()
{
cool;
long long int t;
cin>>t;
while(t--)
{
long long int str,intt,exp,a=0,res=0;
cin>>str>>intt>>exp;
str+=exp;
if(str<=intt)
cout<<"0\n";
else if(str>intt&&exp==0)
cout<<"1\n";
else
{
a=str-intt;
if(a%2==0)
res=(a/2);
else if(a%2!=0)
res=((a/2)+1);
if(res>(exp+1))
res=exp+1;
cout<<res<<"\n";
}
}
return 0;
}