11689

#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
	int t;
	int e,f,c;
	int total_consumed,total_empty;
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d%d%d",&e,&f,&c);
		total_consumed=0;
		total_empty=e+f;
		while(total_empty>=c)
		{
			total_consumed += (total_empty/c);
			total_empty = total_empty/c + total_empty%c;
		}
		cout<<total_consumed<<"\n";
	}
	return 0;
}

 

Leave a Reply

Your email address will not be published. Required fields are marked *