-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAlarm Clock.cpp
More file actions
43 lines (43 loc) · 865 Bytes
/
Copy pathAlarm Clock.cpp
File metadata and controls
43 lines (43 loc) · 865 Bytes
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
38
39
40
41
42
43
#include<bits/stdc++.h>
#define ls long long signed
#define ll long long int
#define fr for (int i=0; i<n; i++)
#define pf printf
#define dl double
using namespace std;
int main()
{
ll t;
cin>>t;
while(t--)
{
ll a,b,c,d;
cin>>a>>b>>c>>d;
ll time;
if(b>=a)
{
time=b;
}
else
{
if(d>=c)
{
time=-1;
}
else
{
ll s,m,n;
s=a-b;
n=c-d;
m;
if(s%n==0)
m=s/n;
else
m=s/n +1;
time=b+(m*c);
}
}
cout<<time<<endl;
}
return 0;
}