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.
The first line contains two integers a and 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.
3 7
Dasha
5 3
Masha
2 3
Equal 求最小公倍数;#include<stdio.h> #include<string.h> #include<math.h> #include<string> #include<iostream> #include<algorithm> #include<vector> #include<queue> #include<list> #include<map> #include<set> using namespace std; int fi,se; int gcd(int a,int b){ if(b==0) return a; return gcd(b,a%b); } int main() { // freopen("in.in","r",stdin); while(~scanf("%d%d",&fi,&se)){ int r=gcd(fi,se); long long res= 1ll * fi / r * se ; int t1=res/fi; int t2=res/se; if(t1>t2 ) t2++; else if( t2 > t1 ) t1++; if(t1 == t2 ) printf("Equal\n"); else if( t1 > t2) printf("Dasha\n"); else printf("Masha\n"); } return 0; }