Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ahmed radwan #161

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Level 1/Class 3/Practice G1/Week 12/D.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <bits/stdc++.h>

using namespace std;

int truckloads(int n, int l) {
if (n <= l)
return 1;
if (n % 2 == 0)
return truckloads(n / 2, l) + truckloads(n / 2, l);
else
return truckloads(n / 2, l) + truckloads(n / 2 + 1, l);

}

int main() {
int n, l;
while (cin >> n >> l)
cout << truckloads(n, l) << endl;
return 0;
}


26 changes: 26 additions & 0 deletions Level 1/Class 3/Practice G1/Week 12/E.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include <bits/stdc++.h>

using namespace std;
//bool sumOfProduct(vector<int> a, vector<int> b, int sum, int i) {
// if (i == a.size()) {
// if (sum == 0)return true;
// else return false;
// }
// sum += a[i] * b[i];
// return sumOfProduct(a, b, sum, i + 1);
//}
int main() {
int n;
cin >> n;
vector<int> a(n), b(n);
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
int sum = 0;
for (int i = 0; i < n; ++i) {
cin >> b[i];
sum += a[i] * b[i];
}
cout << ((sum == 0) ? "Yes" : "No");
return 0;
}
23 changes: 23 additions & 0 deletions Level 1/Class 3/Practice G1/Week 12/F.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

#include <bits/stdc++.h>

using namespace std;

int main() {
int n, s, d;
cin >> n >> s >> d;
bool check = false;
while (n--) {
int x, y;
cin >> x >> y;
if (x >= s or y <= d) {

}
else {
check = true;
}
}
if (check)cout << "Yes";
else cout << "No";
return 0;
}
18 changes: 18 additions & 0 deletions Level 1/Class 3/Practice G1/Week 12/G.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <iostream>
using namespace std;
bool sol(int i, string s,char st,char ed) {
if (i >= s.size())
return 1;
if (s[i] < st or s[i] > ed)
return 0;
return sol(i + 2, s,st,ed);
}
int main() {
string s;
cin >> s;
bool z = sol(0, s,'a','z');
bool zz = sol(1, s,'A','Z');
if (z and zz)cout << "Yes";
else cout << "No";
return 0;
}
17 changes: 17 additions & 0 deletions Level 1/Class 3/Practice G1/Week 12/H.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <iostream>

using namespace std;

int main() {
int t;
cin >> t;
long long mn = 1e18;
while (t--) {
long long a, p, x;
cin >> a >> p >> x;
if (x - a > 0)mn = min(mn, p);
}
if (mn == 1e18)mn = -1;
cout << mn;
return 0;
}
14 changes: 14 additions & 0 deletions Level 1/Class 3/Practice G1/Week 12/I.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <bits/stdc++.h>

using namespace std;

int main() {
int n, x;
cin >> n >> x;
for (int i = 0; i < n; ++i) {
int num;
cin >> num;
if (num != x)cout << num << " ";
}
return 0;
}
13 changes: 13 additions & 0 deletions Level 1/Class 3/Practice G1/Week 12/J.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <bits/stdc++.h>

using namespace std;

int main() {
string s;
cin >> s;
for (auto i: s) {
if (i != '.')cout << i;
else break;
}
return 0;
}
18 changes: 18 additions & 0 deletions Level 1/Class 3/Practice G1/Week 12/K.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <iostream>
#include <vector>
#include "algorithm"

using namespace std;

int sol(int cnt, int limit, int sum) {
if (sum >= limit)return cnt;
sum += cnt;
cnt++;
return sol(cnt, limit, sum);
}

int main() {
int n;
cin >> n;
cout << sol(1, n, 0) - 1 ;
}
39 changes: 39 additions & 0 deletions Level 1/Class 3/Practice G1/Week 12/L.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

#include <iostream>
#include <vector>
#include "algorithm"

using namespace std;

int calcMultiOfDigits(int n) {
if (n < 10) return n;
int product = 1;
while (n != 0) {
int x = n % 10;
if (x != 0)product *= x;
n /= 10;
}
return calcMultiOfDigits(product);
}

int arr[11][1000005];

int main() {
for (int i = 1; i < 1000005; ++i) {
int ans = calcMultiOfDigits(i);
arr[ans][i] = 1;
}
for (int i = 2; i < 1000005; ++i) {
for (int j = 1; j < 10; ++j) {
arr[j][i] += arr[j][i - 1];
}
}
int q;
cin >> q;
while (q--) {
int l, r, k;
cin >> l >> r >> k;
cout << arr[k][r] - arr[k][l - 1] << endl;
}

}
Empty file.
18 changes: 18 additions & 0 deletions Level 1/Scholarship/Practice G1/Week 10/A.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

#include <bits/stdc++.h>

using namespace std;

int main() {
string s;
cin >> s;
set<char> st;
for (int i = 0; i < s.size(); i++) {
st.insert(s[i]);
}
if (st.size() % 2 == 0)
cout << "CHAT WITH HER!" << endl;
else
cout << "IGNORE HIM!" << endl;
return 0;
}
23 changes: 23 additions & 0 deletions Level 1/Scholarship/Practice G1/Week 10/B.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

#include <bits/stdc++.h>

using namespace std;

int main() {
string s;
getline(cin, s);
set<char> st;
// 0123456789
// {b, a, b, a}
for (int i = 1; i < s.size(); i += 3) {
st.insert(s[i]);
}
cout << st.size();

return 0;
}





28 changes: 28 additions & 0 deletions Level 1/Scholarship/Practice G1/Week 10/C.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

#include <bits/stdc++.h>

using namespace std;

int main() {
int t;
cin >> t;
while (t--) {
string s1, s2;
cin >> s1 >> s2;
set<char> st1, st2;
for (auto i: s1)st1.insert(i);
for (auto i: s2)st2.insert(i);
bool print = 0;
for (auto i: st1) {
for (auto j: st2) {
if (i == j) {
cout << "YES" << endl;
print = 1;
break;
}
}
if (print == 1)break;
}
if (print == 0)cout << "NO" << endl;
}
}
23 changes: 23 additions & 0 deletions Level 1/Scholarship/Practice G1/Week 10/D.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <string>
#include <iostream>
using namespace std;
int main(){
string keyboard = "qwertyuiopasdfghjkl;zxcvbnm,./";
char c;
cin >> c;
string happy;
cin >> happy;
for (int i = 0; i < happy.size(); i++){
for (int j = 0; j < keyboard.size(); j++){
if (happy[i] == keyboard[j]){
if (c == 'L')
cout << keyboard[j + 1];
else
cout << keyboard[j - 1];
}
}
}


return 0;
}
16 changes: 16 additions & 0 deletions Level 1/Scholarship/Practice G1/Week 10/E.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <bits/stdc++.h>

using namespace std;

int main() {
int t;
cin >> t;
map<string, int> mp;
while (t--) {
string s;
cin >> s;
mp[s]++;
if (mp[s] == 1)cout << "OK" << endl;
else cout << s << mp[s] - 1 << endl;
}
}
21 changes: 21 additions & 0 deletions Level 1/Scholarship/Practice G1/Week 10/F.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

#include <bits/stdc++.h>

using namespace std;

int main() {
int n;
cin >> n;
vector<string> v;
while (n--) {
string s;
cin >> s;
v.push_back(s);
}
reverse(v.begin(), v.end());
map<string, bool> mp;
for (auto i: v) {
if (mp[i] == 0)cout << i << endl, mp[i] = 1;
}

}
21 changes: 21 additions & 0 deletions Level 1/Scholarship/Practice G1/Week 10/G.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include <bits/stdc++.h>

using namespace std;

int main() {
int n, m, x, y;
cin >> n >> m;
set<int> s;
while (n--) {
cin >> x;
while (x--) {
cin >> y;
s.insert(y);
}
}
if (s.size() == m) {
cout << "YES";
} else
cout << "NO";
return 0;
}
25 changes: 25 additions & 0 deletions Level 1/Scholarship/Practice G1/Week 10/H.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <bits/stdc++.h>

using namespace std;

int main() {
int t;
cin >> t;
int n, m;
while (t--) {
cin >> n >> m;
map<int,int>freq;
int ans = 0;
for (int i = 0; i < n; i++) {
int x;
cin >> x;
freq[x]++;
}
for (int i = 0; i < m; i++) {
int x;
cin >> x;
if (freq[x]) ans++;
}
cout << ans << endl;
}
}
Loading