CF1562A.The Miracle and the Sleeper
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given two integers l and r, l≤r. Find the largest possible value of amodb over all pairs (a,b) of integers for which r≥a≥b≥l.
As a reminder, amodb is a remainder we get when dividing a by b. For example, 26mod8=2.
给你两个整数 l 和 r,满足 l≤r。在所有满足 r≥a≥b≥l 的整数对 (a,b) 中,求 amodb 的最大可能值。
需要提醒的是,amodb 表示将 a 除以 b 所得的余数。例如,26mod8=2。
输入格式
Each test contains multiple test cases.
The first line contains one positive integer t (1≤t≤104), denoting the number of test cases. Description of the test cases follows.
The only line of each test case contains two integers l, r (1≤l≤r≤109).
每个测试包含多个测试用例。
第一行包含一个正整数 t(1≤t≤104),表示测试用例的数量。随后是各测试用例的描述。
每个测试用例仅有一行,包含两个整数 l 和 r(1≤l≤r≤109)。
输出格式
For every test case, output the largest possible value of amodb over all pairs (a,b) of integers for which r≥a≥b≥l.
对于每个测试用例,输出所有满足 r≥a≥b≥l 的整数对 (a,b) 中 amodb 的最大可能值。
输入输出样例
输入#1
4 1 1 999999999 1000000000 8 26 1 999999999
输出#1
0 1 12 499999999
说明/提示
In the first test case, the only allowed pair is (a,b)=(1,1), for which amodb=1mod1=0.
In the second test case, the optimal choice is pair (a,b)=(1000000000,999999999), for which amodb=1.
在第一个测试用例中,唯一允许的数对是 (a,b)=(1,1),此时 amodb=1mod1=0。
在第二个测试用例中,最优选择是数对 (a,b)=(1000000000,999999999),此时 amodb=1。
输入解题思路,AI测评打分。不知道怎么写?