ZOJ - 3948 Marjar Cola 简单模拟
2017-12-03 19:44
441 查看
#include<iostream> #include<algorithm> #include<cstdio> #include<cstdlib> #include<cstring> #include<string> #include<cmath> #include<set> #include<queue> #include<stack> #include<map> #define PI acos(-1.0) #define in freopen("in.txt", "r", stdin) #define out freopen("out.txt", "w", stdout) #define kuaidian ios::sync_with_stdio(0); using namespace std; typedef long long ll; typedef unsigned long long ull; const int maxn = 100 + 7, maxd = 1e8; const ll mod = 1e9 + 7; const int INF = 0x7f7f7f7f; int main (){ ios::sync_with_stdio(0); int t; cin >> t ; for (int i = 0 ; i < t; i ++){ int x,y,a,b; int ans = 0; cin >> x >> y >> a >> b; if (x == 1 || y == 1){ cout << "INF" << endl; } else if (x == 2 && y ==2 && (a >=2 ||b >=2)){ cout << "INF" <<endl; } else { int res , cnt; res = a; cnt = b; //cout << "++++"; while(res >=x || cnt >= y){ int tmp = 0; int tmp1 = 0; tmp += res / x; res = res - tmp * x;// + tmp; tmp1 += cnt / y; cnt = cnt - tmp1 * y;// + tmp1; //cout << res <<" "<<cnt <<" "<<tmp <<" " << tmp1 <<endl; res += (tmp + tmp1); cnt += (tmp + tmp1); ans =ans +tmp + tmp1; } cout << ans <<endl; } } }
相关文章推荐
- ZOJ 3804 YY's Minions (简单模拟)
- zoj1494 暴力模拟 简单数学问题
- Marjar Cola(zoj 3948)
- zoj 3697 恶心模拟 +简单DP
- ZOJ 3827 简单数学推导+简单模拟
- ZOJ 1057 Undercut(简单模拟)
- zoj 2164 Hanafuda Shuffle简单模拟(2)
- ZOJ 3948 Marjar Cola
- ZOJ-3594 Sexagenary Cycle【简单模拟】
- ZOJ 3542 2011大连现场赛D题(简单模拟)
- ZOJ 3804 YY's Minions(简单模拟)
- ZOJ 3220 Killing Streak(简单模拟)
- zoj 2417 Lowest Bit(简单的模拟)
- ZOJ 3778 Talented Chef(找规律,模拟计算,11届ACM省赛,简单)
- zoj3948——Marjar Cola
- zoj 3948 Marjar Cola
- ZOJ 3542 2011大连现场赛D题(简单模拟)
- FZOJ Problem 2183 简单题
- zoj2740-简单并查集
- Python爬虫学习(简单的模拟登陆(一))