Type: Default File IO: number 1000ms 256MiB

报数

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

题目描述

nn个人,从11开始报数,报到kk,再变成11,也就是报数序列是1,2,3,...,k,k1,...,2,1,2,3,...1,2,3,...,k,k-1,...,2,1,2,3,...

现在已知你是第nn个人,报的是xx,问:kk有多少种不同的可能。

注意:kk在本题中一定是2\geq 2的。

输入格式

第一行输入TT,一共TT组数据。

接下来TT行,每行输入n,xn,x

输出格式

对于每组数据,输出一个数字表示答案。

5
10 2
3 1
76 4
100 99
1000000000 500000000
4
1
9
0
1

数据范围

对于20%的数据:保证n1000n\leq 1000

对于40%的数据:保证n104n\leq 10^4

对于50%的数据:保证n105n\leq 10^5

对于70%的数据:保证n5×105n\leq 5\times 10^5

对于100%的数据:保证1T1001\leq T\leq 1001x<n1091\leq x<n\leq 10^9

0906

Not Attended
Status
Done
Rule
IOI
Problem
7
Start at
2025-9-6 14:00
End at
2025-9-6 18:00
Duration
4 hour(s)
Host
Partic.
61