CF1182F.Maximum Sine
省选/NOI-
通过率:0%
时间限制:3.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You have given integers a, b, p, and q. Let f(x)=abs(sin(qpπx)).
Find minimum possible integer x that maximizes f(x) where a≤x≤b.
已知整数 a、b、p 和 q。令 f(x)=abs(sin(qpπx))。
在满足 a≤x≤b 的整数 x 中,求使 f(x) 取得最大值的最小可能整数 x。
输入格式
Each test contains multiple test cases.
The first line contains the number of test cases t (1≤t≤100) — the number of test cases.
The first line of each test case contains four integers a, b, p, and q (0≤a≤b≤109, 1≤p, q≤109).
每个测试包含多个测试用例。
第一行包含测试用例的数量 t(1≤t≤100)——即测试用例的个数。
每个测试用例的第一行包含四个整数 a、b、p 和 q(0≤a≤b≤109,1≤p,q≤109)。
输出格式
Print the minimum possible integer x for each test cases, separated by newline.
对每个测试用例,输出可能的最小整数 x,各结果之间用换行符分隔。
输入输出样例
输入#1
2 0 3 1 3 17 86 389 995
输出#1
1 55
说明/提示
In the first test case, f(0)=0, f(1)=f(2)≈0.866, f(3)=0.
In the second test case, f(55)≈0.999969, which is the largest among all possible values.
在第一个测试用例中,f(0)=0,f(1)=f(2)≈0.866,f(3)=0。
在第二个测试用例中,f(55)≈0.999969,是所有可能取值中的最大值。
输入解题思路,AI测评打分。不知道怎么写?