Skip to content

Commit 8289af3

Browse files
Merge pull request #8 from mairohanhoon/main
BEGINNERS CONTEST 44: Problems added.
2 parents 826ec5d + 1437365 commit 8289af3

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#include<bits/stdc++.h>
2+
using namespace std;
3+
4+
int makeEvenSum(int n, vector<int> &a) {
5+
// Write your code here.
6+
int odd = 0;
7+
int even = 0;
8+
for(int i=0; i<n; i++){
9+
if(a[i]%2 == 0){
10+
even++;
11+
}
12+
else{
13+
odd++;
14+
}
15+
}
16+
if(odd%2!=0 && even==0){
17+
return 0;
18+
}
19+
else{
20+
return 1;
21+
}
22+
}
23+
24+
int main(){
25+
int n = 4;
26+
vector<int> arr = {1, 5, 5, 10};
27+
cout << makeEvenSum(n, arr) << endl;
28+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include<bits/stdc++.h>
2+
using namespace std;
3+
4+
int numberOfGoodIndices(int n, vector<int>& a) {
5+
// Write Your Code Here.
6+
int count = 0;
7+
int temp = 0;
8+
for(int i=0; i<n; i++){
9+
temp = 0;
10+
for(int j=0; j<n; j++){
11+
if(i!=j && a[i] % a[j] == 0){
12+
temp++;
13+
}
14+
}
15+
if(temp >= 2){
16+
count++;
17+
}
18+
}
19+
return count;
20+
}
21+
22+
int main(){
23+
int n = 5;
24+
vector<int> a = {4, 2, 2, 6, 7};
25+
cout << numberOfGoodIndices(n, a);
26+
}

0 commit comments

Comments
 (0)