-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA_Even_Odds.cpp
More file actions
43 lines (41 loc) · 895 Bytes
/
A_Even_Odds.cpp
File metadata and controls
43 lines (41 loc) · 895 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>
using namespace std;
int main()
{
int a, b;
cin >> a >> b;
int div; // if (a % 2 != 0)
// div++;
if(a % 2 == 0){
div = a / 2;
}
if(a % 2 != 0 ){
div = a / 2;
div++;
}
// cout << div << ' ';
int oddd = 0,evenn=0;
// even number , less then a/2
if (b <= div){
for (int i = 1; i <= 10; i++){
if (i % 2 != 0){
oddd++;
if (oddd == b){
cout << i << endl;
}
}
}
}
if(b > div){
for(int i = 1; i <= 10; i++){
if(i % 2 == 0 ){
evenn++;
if(evenn == (a - div)){
cout << i << endl;
break;
}
}
}
}
return 0;
}