Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- unsigned long long gcd(long a, long b) {
- return b == 0 ? a : gcd(b, a % b);
- }
- int main(int argc, const char * argv[]) {
- unsigned long long v1,d1,v2,d2,iGcd,fTop,fBot,tL,tR;
- unsigned long long i = 1;
- while(cin >> v1 && v1 !=0){
- cin >> d1 >> v2 >> d2;
- fTop = (d2*v1)+(d1*v2);
- fBot = v1 * v2 * 2;
- iGcd = gcd(fTop, fBot);
- if(tR>tL){
- cout << "Case #" << i << ": You owe me a beer!" << endl;
- cout << "Avg. arrival time: " << (fTop/iGcd);
- if(iGcd != fBot){
- cout << "/" << (fBot/iGcd) << endl;
- }
- else{
- cout << endl;
- }
- }
- else {
- cout << "Case #" << i << ": No beer for the captain."<< endl;
- cout << "Avg. arrival time: " << (fTop/iGcd);
- if(iGcd != fBot){
- cout << "/" << (fBot/iGcd) << endl;
- }
- else{
- cout << endl;
- }
- }
- i++;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement