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: 2018212212067
In contest: 1277

#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int main()
{
	int t;
    scanf("%d",&t);
    while(t--)
    {
        int flag = 0;
        double a,b,sum = 0;
        int x;
        scanf("%lf %lf %d",&a,&b,&x);
        while(sum < x)
        {
            int k = ceil(a/b - 1);
            double dx = (a - b * k) / (2 * k + 1);
            dx = dx<(x-sum)?dx:x - sum;
            a -= dx * (2 * k + 1);
            sum += dx;
            if(a < b && sum + b < x)
            {
                flag = 1;
                break;
            }
        }
        if(flag)
            puts("-1");
        else
            printf("%.5f\n",a);
    }
	return 0;
}