Start: Jul, 01, 2019 08:30:00
2019年度暑期短学期第四天
End: Jul, 01, 2019 11:30:00
Time elapsed:
Time remaining:

Problem_ID: F
Result: Accepted
Time: 5ms
Memory: 1120kB
Author: 2018212212128
In contest: 1277

#include<stdio.h>
#include<math.h>
double min(double a,double b)
{
	if(a>=b)
		return b;
	else 
		return a;
}
int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		double a,b,x;
		scanf("%lf %lf %lf",&a,&b,&x);
		if(a<x)
		{
			printf("-1\n");
			continue;
		}
		int k=ceil(a/b);
		double now=0;
		while(now<x)
		{
			int cnt=2*k-1;
			double tmp=(a-b*(k-1))/cnt;
			tmp=min(x-now,tmp);
			now+=tmp;
			a-=cnt*tmp;
			if(x-now>b&&a<b)
			{
				a=-1;
				break;
			}
			k--;
		}
		if (a<0)
			printf("-1\n");
		else
			printf("%.5lf\n",a);
	}
	return 0;
}