File tree 4 files changed +97
-3
lines changed
4 files changed +97
-3
lines changed Original file line number Diff line number Diff line change
1
+ #include < bits/stdc++.h>
2
+ using namespace std ;
3
+
4
+ bool isValid (int i)
5
+ {
6
+ bool check = true ;
7
+ while (i > 0 )
8
+ {
9
+ int rem = i % 10 ;
10
+ if (rem != 4 || rem != 7 ) // conditions to check for validity
11
+ check = false ;
12
+ i = i / 10 ;
13
+ }
14
+ return check;
15
+ }
16
+
17
+ int main ()
18
+ {
19
+ int a, b;
20
+ cin >> a >> b; // input from user
21
+ int cnt = 0 ;
22
+ for (int i = a; i <= b; i++)
23
+ {
24
+ if (isValid (i)) // checking validity for each number in range a to b
25
+ {
26
+ cnt++;
27
+ cout << i << " " ;
28
+ }
29
+ }
30
+ if (cnt == 0 ) // if no number is valid then print -1
31
+ cout << -1 << endl;
32
+ return 0 ;
33
+ }
Original file line number Diff line number Diff line change
1
+ #include < bits/stdc++.h>
2
+ using namespace std ;
3
+
4
+ int main ()
5
+ {
6
+ char ch;
7
+ cin >> ch; // input character
8
+ int n;
9
+ cin >> n;
10
+ vector<int > v (n);
11
+ for (int i = 0 ; i < n; i++)
12
+ cin >> v[i]; // input
13
+ for (auto i : v)
14
+ {
15
+ for (int j = 0 ; j < i; j++)
16
+ {
17
+ cout << ch; // printing the character Xi times
18
+ }
19
+ cout << endl;
20
+ }
21
+ return 0 ;
22
+ }
Original file line number Diff line number Diff line change
1
+ #include < bits/stdc++.h>
2
+ using namespace std ;
3
+
4
+ int main ()
5
+ {
6
+ int n, q;
7
+ cin >> n >> q; // input from user
8
+ vector<int > v (n);
9
+ for (int i = 0 ; i < n; i++)
10
+ cin >> v[i];
11
+ sort (v.begin (), v.end ()); // sorting the vector to apply binary search
12
+ while (q--)
13
+ {
14
+ int target;
15
+ cin >> target;
16
+ bool check = false ;
17
+ int start = 0 , end = n - 1 ;
18
+ while (start <= end) // running Binary Search for each query
19
+ {
20
+ int mid = start + (end - start) / 2 ;
21
+ if (v[mid] == target)
22
+ {
23
+ check = true ;
24
+ break ;
25
+ }
26
+ else if (v[mid] < target)
27
+ {
28
+ start = mid + 1 ;
29
+ }
30
+ else
31
+ end = mid - 1 ;
32
+ }
33
+ if (check) // condition
34
+ cout << " found" << endl;
35
+ else
36
+ cout << " not found" << endl;
37
+ }
38
+ return 0 ;
39
+ }
Original file line number Diff line number Diff line change @@ -91,8 +91,8 @@ In the "Repository" you will find the topics and its problems.
91
91
|11|[ Primes from 1 to n] ( https://codeforces.com/group/MWSDmqGsZm/contest/219432/problem/J ) | [ C++] ( ./C++/37_Primes_from_1to_n.cpp )
92
92
|12|[ Divisors] ( https://codeforces.com/group/MWSDmqGsZm/contest/219432/problem/K ) | [ C++] ( ./C++/38_Divisors.cpp )
93
93
|13|[ GCD] ( https://codeforces.com/group/MWSDmqGsZm/contest/219432/problem/L ) | [ C++] ( ./C++/13_GCD.cpp )
94
- |14|[ Lucky Numbers] ( https://codeforces.com/group/MWSDmqGsZm/contest/219432/problem/M )
95
- |15|[ Numbers Histogram] ( https://codeforces.com/group/MWSDmqGsZm/contest/219432/problem/N )
94
+ |14|[ Lucky Numbers] ( https://codeforces.com/group/MWSDmqGsZm/contest/219432/problem/M ) | [ C++ ] ( ./C++/14_Lucky_Numbers.cpp )
95
+ |15|[ Numbers Histogram] ( https://codeforces.com/group/MWSDmqGsZm/contest/219432/problem/N ) | [ C++ ] ( ./C++/15_Numbers_Histogram.cpp )
96
96
|16|[ Pyramid] ( https://codeforces.com/group/MWSDmqGsZm/contest/219432/problem/O ) | [ C++] ( ./C++/42_Pyramid.cpp )
97
97
|17|[ Shape1] ( https://codeforces.com/group/MWSDmqGsZm/contest/219432/problem/P ) | [ C++] ( ./C++/43_Shape1.cpp )
98
98
|18|[ Digits] ( https://codeforces.com/group/MWSDmqGsZm/contest/219432/problem/Q ) | [ C++] ( ./C++/44_Digits.cpp )
@@ -135,7 +135,7 @@ In the "Repository" you will find the topics and its problems.
135
135
|23|[ Mirror Array] ( https://codeforces.com/group/MWSDmqGsZm/contest/219774/problem/W ) | [ C++] ( ./C++/mirror.cpp )
136
136
|24|[ 8 Neighbors] ( https://codeforces.com/group/MWSDmqGsZm/contest/219774/problem/X ) | [ C++] ( ./C++/neighbours.cpp )
137
137
|25|[ Range sum query] ( https://codeforces.com/group/MWSDmqGsZm/contest/219774/problem/Y ) | [ C++] ( ./C++/rangeSumQuery.cpp )
138
- |26|[ Binary Search] ( https://codeforces.com/group/MWSDmqGsZm/contest/219774/problem/Z )
138
+ |26|[ Binary Search] ( https://codeforces.com/group/MWSDmqGsZm/contest/219774/problem/Z ) | [ C++ ] ( ./C++/26_Binary_Search.cpp )
139
139
140
140
## Strings
141
141
You can’t perform that action at this time.
0 commit comments