Skip to content

Commit 7361cc4

Browse files
authored
Merge pull request #14 from mairohanhoon/main
ADDED WEEKEND CONTEST 94
2 parents 9f1bc5f + 8f16ef9 commit 7361cc4

File tree

3 files changed

+98
-0
lines changed

3 files changed

+98
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#include<bits/stdc++.h>
2+
using namespace std;
3+
4+
int goodPartition(int n, vector<int> v) {
5+
// Write your code here.
6+
sort(v.begin(), v.end());
7+
if(n == 2){
8+
if(v[0] != v[1]){
9+
return 1;
10+
}
11+
else{
12+
return 0;
13+
}
14+
}
15+
else{
16+
if(v[v.size()/2] != v[(v.size()/2)-1]){
17+
return 1;
18+
}
19+
else{
20+
return 0;
21+
}
22+
}
23+
}
24+
25+
int main(){
26+
27+
vector<int> v = {1, 3, 2, 2};
28+
int n = 4;
29+
30+
cout << goodPartition(n, v);
31+
32+
return 0;
33+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include<bits/stdc++.h>
2+
using namespace std;
3+
4+
int joeAndCheeseCake(int n, int m) {
5+
// Write your code here.
6+
if(n%m == 0){
7+
return n/m;
8+
}
9+
else{
10+
return (n/m)+1;
11+
}
12+
}
13+
int main(){
14+
15+
int n = 5;
16+
int m = 3;
17+
18+
cout << joeAndCheeseCake(n, m);
19+
20+
return 0;
21+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#include<bits/stdc++.h>
2+
using namespace std;
3+
4+
int primeReversePrime(int l, int r) {
5+
// Write your code here.
6+
int x = l;
7+
int count = 0;
8+
while(x<=r){
9+
int rev = 0;
10+
int temp = x;
11+
while(temp!=0){
12+
rev = (rev*10)+temp%10;
13+
temp/=10;
14+
}
15+
temp = x;
16+
int check1 = 0;
17+
for(int i=1; i<=temp; i++){
18+
if(temp%i == 0){
19+
check1++;
20+
}
21+
}
22+
int check2 = 0;
23+
for(int i=1; i<=rev; i++){
24+
if(rev%i == 0){
25+
check2++;
26+
}
27+
}
28+
if(check1 == 2 && check2 == 2){
29+
count++;
30+
}
31+
x++;
32+
}
33+
return count;
34+
}
35+
36+
int main(){
37+
38+
int l = 4;
39+
int r = 10;
40+
41+
cout << primeReversePrime(l, r);
42+
43+
return 0;
44+
}

0 commit comments

Comments
 (0)