题目

题意:要做N天活,其中质量好至少(n+1)/2天,然后先g天好,b天不好。

思路:找出至少需要(n+1)/2天好的最少天数S,如果>n天,则答案为S,如果小于n天则剩下还要干活的天数全用质量差的也可,答案为n。

Code:

#include<iostream>
#include<string>
#include<map>
#include<algorithm>
#include<memory.h>
#include<cmath>
#define pii pair<int,int>
#define FAST ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
typedef long long ll;
const int Max = 1e6 + 5;
int lst[Max];
int Mod = 1e9 + 7;

int main()
{
   
	int t;cin >> t;
	while (t--)
	{
   
		ll n, g, b, c = 0;
		cin >> n >> g >> b;
		int t = (n + 1) / 2 / g;
		if ((n + 1) / 2 % g == 0)
		{
   
			t--;c += g;
		}
		else c += (n + 1) / 2 % g;
		c += t * (g + b);
		if (c <= n)cout << n << endl;
		else cout << c << endl;
	}
}