Skip to content

Commit 5c75bb1

Browse files
authored
Solved issue #46 completely (adityabisoi#222)
* Delete solution.cpp * Create solution.cpp * Create solution.cpp * Update solution.cpp * Create solution.cpp * Create solution.cpp * Update README.md
1 parent f2177f1 commit 5c75bb1

File tree

5 files changed

+64
-3
lines changed

5 files changed

+64
-3
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
int main()
5+
{
6+
int s,t,a,b,m,n,ap,apcnt = 0,ora,orcnt = 0;
7+
8+
cin >> s >> t >> a >> b >> m >> n; //taking all the variable inputs
9+
10+
for(int i = 0; i < m; i++)
11+
{
12+
cin >> ap;
13+
if(a+ap >= s && a+ap <= t) apcnt++; //checking the condition of weather apple will fall in his house and incrementing the counter if yes
14+
}
15+
16+
for(int i = 0;i < n;i++)
17+
{
18+
cin >> ora;
19+
if(b+ora >= s && b+ora <= t)orcnt++; //checking the condition of weather orange will fall in his house and incrementing the counter if yes
20+
}
21+
cout << apcnt <<endl<< orcnt << endl; //outputting the calculated counts
22+
return 0;
23+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include<bits/stdc++.h>
2+
using namespace std;
3+
4+
int main(){
5+
int n,a;
6+
vector<int> ar;
7+
for(int i = 40; i <= 100 ; i+=5)
8+
ar.push_back(i); //creating an vector of numbers from 40 to 100 which are multiple of 5
9+
cin >> n;
10+
for(int i = 0; i < n; i++){
11+
cin >> a;
12+
bool flag = true; //flag to make sure a number is not printed twice
13+
for(int j = 0; j < ar.size(); j++){
14+
if(ar[j] - a < 3 && (ar[j] - a) > 0){ //checking if the number we want to round off to satisfies the condition
15+
cout << ar[j] << endl;
16+
flag = false; //setting flag false so it doesn't print again in the end
17+
break;
18+
}
19+
}
20+
if(flag)cout << a << endl;
21+
}
22+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
int main(){
5+
int x1, x2, v1, v2;
6+
cin >> x1 >> v1 >> x2 >> v2;
7+
8+
if((x2>x1 && v2>=v1) || (x1>x2 && v1>=v2)) // ahead and faster
9+
cout<<"NO";
10+
else // behind and faster
11+
if (!((x2-x1)%(v2-v1)) ) //check if its perfectly divisible so you can land
12+
cout<<"YES";
13+
else
14+
cout<<"NO";
15+
return 0;
16+
}

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ Please add the link to the README as well. The folder structure `Arrays/Left Rot
6565
||[Swap Nodes [Algo]](https://www.hackerrank.com/challenges/swap-nodes-algo/problem)|Medium|[View](Trees/Tree-%20Swap%20Nodes%20[Algo]/solution.cpp)|[View](Trees/Tree-%20Swap%20Nodes%20[Algo]/solution.java)||
6666
||[Tree: Huffman Decoding](https://www.hackerrank.com/challenges/tree-huffman-decoding/problem)|Medium|[View](Trees/Tree%20Huffman%20Decoding/solution.cpp)||[View](Trees/Tree%20Huffman%20Decoding/solution.py)|
6767
| Algorithms |
68-
||[Grading Students](https://www.hackerrank.com/challenges/grading/problem)|Easy||[View](/Algorithms/Grading%20Students/solution.java)|[View](/Algorithms/Grading%20Students/solution.py)|
69-
||[Apple and Orange](https://www.hackerrank.com/challenges/apple-and-orange/problem)|Easy|||[View](/Algorithms/Apple%20and%20Orange/solution.py)|
70-
||[Number Line Jumps](https://www.hackerrank.com/challenges/kangaroo/problem)|Easy|||[View](Algorithms/Number%20Line%20Jump/solution.py)|
68+
||[Grading Students](https://www.hackerrank.com/challenges/grading/problem)|Easy|[View](/Algorithms/Grading%20Students/solution.cpp)|[View](/Algorithms/Grading%20Students/solution.java)|[View](/Algorithms/Grading%20Students/solution.py)|
69+
||[Apple and Orange](https://www.hackerrank.com/challenges/apple-and-orange/problem)|Easy|[View](/Algorithms/Apple%20and%20Orange/solution.cpp)||[View](/Algorithms/Apple%20and%20Orange/solution.py)|
70+
||[Number Line Jumps](https://www.hackerrank.com/challenges/kangaroo/problem)|Easy|[View](Algorithms/Number%20Line%20Jump/solution.cpp)||[View](Algorithms/Number%20Line%20Jump/solution.py)|
7171
||[Encryption](https://www.hackerrank.com/challenges/encryption/problem)|Medium|||[View](Algorithms/Encryption/solution.py)|
7272
||[Breaking the Records](https://www.hackerrank.com/challenges/breaking-best-and-worst-records/problem)|Easy|[View](/Algorithms/Breaking%20the%20Records/solution.cpp)|[View](/Algorithms/Breaking%20the%20Records/solution.java)||
7373
||[Sales by Match](https://www.hackerrank.com/challenges/sock-merchant/problem)|Easy|[View](/Algorithms/Sales%20by%20Match/solution.cpp)|[View](/Algorithms/Sales%20by%20Match/solution.java)||

0 commit comments

Comments
 (0)