CF87A.Trains
普及/提高-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Vasya the programmer lives in the middle of the Programming subway branch. He has two girlfriends: Dasha and Masha, who live at the different ends of the branch, each one is unaware of the other one's existence.
When Vasya has some free time, he goes to one of his girlfriends. He descends into the subway at some time, waits the first train to come and rides on it to the end of the branch to the corresponding girl. However, the trains run with different frequencies: a train goes to Dasha's direction every a minutes, but a train goes to Masha's direction every b minutes. If two trains approach at the same time, Vasya goes toward the direction with the lower frequency of going trains, that is, to the girl, to whose directions the trains go less frequently (see the note to the third sample).
We know that the trains begin to go simultaneously before Vasya appears. That is the train schedule is such that there exists a moment of time when the two trains arrive simultaneously.
Help Vasya count to which girlfriend he will go more often.
程序员瓦夏住在编程地铁线的中段。他有两个女朋友:达莎和玛莎,她们分别住在该地铁线的两端,且彼此互不知晓对方的存在。
当瓦夏有空闲时间时,他会去其中一位女朋友那里。他会在某个时刻进入地铁站,等待第一班到达的列车,并乘坐该列车直达线路尽头——即前往对应女友所在的方向。然而,两个方向的列车发车频率不同:开往达莎方向的列车每 a 分钟一班,而开往玛莎方向的列车每 b 分钟一班。若两列列车同时到达,瓦夏会选择发车频率更低的方向(即列车发车间隔更长的方向)前往——也就是前往那位列车发车更不频繁的女友所在方向(参见第三个样例的注释)。
已知:在瓦夏出现之前,两方向的列车已开始同步运行。也就是说,存在某一时刻,两列列车会同时到达。
请帮助瓦夏计算:他更常去哪位女友那里?
输入格式
The first line contains two integers a and b (a ≠ b, 1 ≤ a, b ≤ 106).
第一行包含两个整数 a 和 b(a=b,1≤a,b≤106)。
输出格式
Print "Dasha" if Vasya will go to Dasha more frequently, "Masha" if he will go to Masha more frequently, or "Equal" if he will go to both girlfriends with the same frequency.
如果瓦夏去达莎家的频率更高,则输出“Dasha”;如果他去玛莎家的频率更高,则输出“Masha”;如果他去两位女友家的频率相同,则输出“Equal”。
输入输出样例
输入#1
3 7
输出#1
Dasha
输入#2
5 3
输出#2
Masha
输入#3
2 3
输出#3
Equal
说明/提示
Let's take a look at the third sample. Let the trains start to go at the zero moment of time. It is clear that the moments of the trains' arrival will be periodic with period 6. That's why it is enough to show that if Vasya descends to the subway at a moment of time inside the interval (0, 6], he will go to both girls equally often.
If he descends to the subway at a moment of time from 0 to 2, he leaves for Dasha on the train that arrives by the second minute.
If he descends to the subway at a moment of time from 2 to 3, he leaves for Masha on the train that arrives by the third minute.
If he descends to the subway at a moment of time from 3 to 4, he leaves for Dasha on the train that arrives by the fourth minute.
If he descends to the subway at a moment of time from 4 to 6, he waits for both trains to arrive by the sixth minute and goes to Masha as trains go less often in Masha's direction.
In sum Masha and Dasha get equal time — three minutes for each one, thus, Vasya will go to both girlfriends equally often.
我们来看第三个样例。假设列车在时刻 0 开始运行。显然,列车到达的时刻具有周期性,周期为 6。因此,只需证明:若瓦夏在时间区间 (0,6] 内的任意时刻进入地铁站,则他前往两位女孩的次数将相等。
- 若他在时刻 0 到 2 之间进入地铁站,则他将搭乘于第 2 分钟到达的列车前往达莎;
- 若他在时刻 2 到 3 之间进入地铁站,则他将搭乘于第 3 分钟到达的列车前往玛莎;
- 若他在时刻 3 到 4 之间进入地铁站,则他将搭乘于第 4 分钟到达的列车前往达莎;
- 若他在时刻 4 到 6 之间进入地铁站,则他将等待两列列车均于第 6 分钟到达,并由于开往玛莎方向的列车班次更少,而选择前往玛莎。
综上,玛莎与达莎各自对应的时间长度均为 3 分钟,因此瓦夏前往两位女友的次数将完全相等。
输入解题思路,AI测评打分。不知道怎么写?