首页 > 编程语言 > 详细

ZOJ 3948: Marjar Cola

时间:2017-08-06 23:48:46      阅读:307      评论:0      收藏:0      [点我收藏+]

Marjar Cola

 

///@author Sycamore, ZJNU
///@date 4/9/2017
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <cctype>
#include<fstream>
#include<cstdio>
//#define cin fin
//#define cout fout
//ifstream fin("in.txt");
//ofstream fout("out.txt");
using namespace std;
typedef vector<int> VI;
typedef pair<int, int> PII;
 
int main()
{
	int T;
	cin >> T;
	while (T--)
	{
		int x, y, a, b;
		cin >> x >> y >> a >> b;
 
		int c = 0, d = 0;
		while (a >= x || b >= y)
		{
			if (a >= x)
			{
				a = a - x + 1;
				b++;
				c++;
			}
			if (b >= y)
			{
				b = b - y + 1;
				a++;
				c++;
			}
			d++;
			if (d == 100000)
			{
 
				break;
			}
		}
		if (d == 100000)cout << "INF" << endl;
		else cout << c << endl;
	}
	return 0;
} 

 

ZOJ 3948: Marjar Cola

原文:http://www.cnblogs.com/zjnu/p/7296382.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!