We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 469f3aa + 3715b93 commit dfc263dCopy full SHA for dfc263d
covid and cousin problem/covid and cousin solution.cpp
@@ -0,0 +1,47 @@
1
+#include<iostream>
2
+using namespace std;
3
+int main()
4
+{
5
+int t,s,d,f,b,m,k;
6
+cin>>k;
7
+for(int i=0;i<k;i++)
8
9
+cin>>t;
10
+cin>>s;
11
+cin>>d;
12
+cin>>f;
13
+cin>>b;
14
+m = 0;
15
+while((s!=d) && (s<=t) && (d<=t))
16
17
+if((s<d) && (f==0))
18
19
+ break;
20
+}
21
+while((s<d) && (f!=0))
22
23
+ s+=f;
24
+ m+=1;
25
26
+if((s>d) && (b==0))
27
28
29
30
+while((s>d) && (b!=0))
31
32
+ s-=b;
33
34
35
+if(s==d)
36
37
+ cout<<m;
38
39
+else
40
41
+ cout<<"Not Reachable";
42
43
44
45
+return 0;
46
47
+
0 commit comments