-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaugustcircit1.c
37 lines (28 loc) · 921 Bytes
/
augustcircit1.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include<stdio.h>
#include<math.h>
void main()
{
int t;
scanf("%d",&t);
while(t--)
{
long long int d,a,m,b,x;
scanf("%lld%lld%lld%lld%lld",&d,&a,&m,&b,&x);
if (d >= x)
printf("0\n");
else
{
long long int result,temp,rem;
result = (x -d) / ((a * m) + b);
temp = result * ((a *m) +b);
result *= m + 1L;
rem = x -d;
if (temp != 0)
rem = (x - d) % temp;
if (rem == 0)
printf("%lld\n",result);
else
printf("%lld\n",result +(long)ceil((rem /(double)a)));
}
}
}