Niro plays Galaxy Note 7

DESCRIPTION

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 (|Xi|R)(|X−i|≤R).You must tell Niro how many cities wil be destroyed.

INPUT
The first line contains a positive integer TT, the number of test cases.Each of the following TT lines contains three integers NN, RR, XX.
OUTPUT
TT lines.Each line contains one integer, the answer.
SAMPLE INPUT
3100 5 23100 8 36100 9 99
SAMPLE OUTPUT
111711
HINT






1
T,N100
1≤T,N≤100
0R1000≤R≤1001X
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,N100
1≤T,N≤100
0R1000≤R≤1001X
N
發佈了59 篇原創文章 · 獲贊 6 · 訪問量 2萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章