Niro, a lovely girl, has bought a Galaxy Note 7 and wants to destroy cities. There are N cities numbered 1... N on a line and each pair of adjacent cities has distance 1. Galaxy Note 7 has its explosion radius R. Niro puts her Galaxy Note 7 in city X and city
i will be destroyed
if (|X−i|≤R)(|X−i|≤R).You
must tell Niro how many cities wil be destroyed.
1≤T,N≤1001≤T,N≤1000≤R≤1000≤R≤1001≤X≤
N
//
// Created by liyuanshuo on 2017/3/18.
//
#include <iostream>
#include <cstdio>
using namespace std;
int main_note_7( )
{
//freopen ("F:\\CSLeaning\\Thinking in C++\\hihocoder\\in.in", "r", stdin);
int t, n, r, x;
cin>>t;
while ( t-- )
{
cin>>n>>r>>x;
int ans = 1;
if( x + r < n )
ans += r;
else
ans += ( n - x );
if( x - r > 0 )
ans += r;
else
ans += (x -1);
cout<<ans<<endl;
}
return 0;
}
1≤T,N≤1001≤T,N≤1000≤R≤1000≤R≤1001≤X≤
N