CF1055C.Lucky Days
普及+/提高
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Bob and Alice are often participating in various programming competitions. Like many competitive programmers, Alice and Bob have good and bad days. They noticed, that their lucky and unlucky days are repeating with some period. For example, for Alice days [la;ra] are lucky, then there are some unlucky days: [ra+1;la+ta−1], and then there are lucky days again: [la+ta;ra+ta] and so on. In other words, the day is lucky for Alice if it lies in the segment [la+kta;ra+kta] for some non-negative integer k.
The Bob's lucky day have similar structure, however the parameters of his sequence are different: lb, rb, tb. So a day is a lucky for Bob if it lies in a segment [lb+ktb;rb+ktb], for some non-negative integer k.
Alice and Bob want to participate in team competitions together and so they want to find out what is the largest possible number of consecutive days, which are lucky for both Alice and Bob.
鲍勃和爱丽丝经常参加各类编程竞赛。和许多竞技程序员一样,爱丽丝和鲍勃也有状态好和状态差的日子。他们注意到,各自的幸运日与不幸运日以某种周期重复出现。例如,对爱丽丝而言,区间 [la;ra] 内的日期是幸运日,接着是一段不幸运日:[ra+1;la+ta−1],然后又进入下一轮幸运日:[la+ta;ra+ta],依此类推。换言之,某一天对爱丽丝而言是幸运日,当且仅当它属于某个形如 [la+kta;ra+kta] 的区间,其中 k 为非负整数。
鲍勃的幸运日也具有类似的结构,但其序列参数不同:lb、rb、tb。因此,某一天对鲍勃而言是幸运日,当且仅当它属于某个形如 [lb+ktb;rb+ktb] 的区间,其中 k 为非负整数。
爱丽丝和鲍勃希望一起组队参加比赛,因此他们想找出最长的连续天数区间,使得该区间内的每一天同时对爱丽丝和鲍勃都是幸运日。
输入格式
The first line contains three integers la, ra, ta (0≤la≤ra≤ta−1,2≤ta≤109) and describes Alice's lucky days.
The second line contains three integers lb, rb, tb (0≤lb≤rb≤tb−1,2≤tb≤109) and describes Bob's lucky days.
It is guaranteed that both Alice and Bob have some unlucky days.
第一行包含三个整数 la、ra、ta(满足 0≤la≤ra≤ta−1,且 2≤ta≤109),用于描述爱丽丝的幸运日。
第二行包含三个整数 lb、rb、tb(满足 0≤lb≤rb≤tb−1,且 2≤tb≤109),用于描述鲍勃的幸运日。
保证爱丽丝和鲍勃均存在一些不幸的日子。
输出格式
Print one integer: the maximum number of days in the row that are lucky for both Alice and Bob.
输出一个整数:Alice 和 Bob 都幸运的连续天数的最大值。
输入输出样例
输入#1
0 2 5 1 3 5
输出#1
2
输入#2
0 1 3 2 3 6
输出#2
1
说明/提示
The graphs below correspond to the two sample tests and show the lucky and unlucky days of Alice and Bob as well as the possible solutions for these tests.


下面的图对应两个样例测试,展示了爱丽丝和鲍勃的幸运日与不幸日,以及这些测试的可能解。


输入解题思路,AI测评打分。不知道怎么写?