Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a8253f8

Browse files
committedAug 15, 2021
Added 4 problems from Codechef's August Challenge 2021 Division 2
1 parent 8c10464 commit a8253f8

File tree

4 files changed

+89
-0
lines changed

4 files changed

+89
-0
lines changed
 

‎Codechef/chef_and_bulb_invention.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
5+
#define long long long int
6+
7+
int main() {
8+
ios_base::sync_with_stdio(false);
9+
cin.tie(NULL);
10+
11+
int T; cin >> T;
12+
while (T--) {
13+
int N, p, K;
14+
cin >> N >> p >> K;
15+
16+
int ans = (p % K) * (N / K);
17+
ans += min(N % K, p % K);
18+
ans += p / K + 1;
19+
20+
cout << ans << "\n";
21+
}
22+
}

‎Codechef/olympics_ranking.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
5+
#define long long long int
6+
7+
int main() {
8+
ios_base::sync_with_stdio(false);
9+
cin.tie(NULL);
10+
11+
int T; cin >> T;
12+
while (T--) {
13+
int G1, S1, B1, G2, S2, B2;
14+
cin >> G1 >> S1 >> B1 >> G2 >> S2 >> B2;
15+
16+
int T1 = G1 + S1 + B1;
17+
int T2 = G2 + S2 + B2;
18+
19+
cout << (T1 > T2 ? "1" : "2") << "\n";
20+
}
21+
}

‎Codechef/problem_difficulties.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
5+
#define long long long int
6+
7+
const int MAX = 15;
8+
9+
int main() {
10+
ios_base::sync_with_stdio(false);
11+
cin.tie(NULL);
12+
13+
int T; cin >> T;
14+
while (T--) {
15+
int cnt[MAX] = {0}, mx = 0;
16+
for (int i = 0; i < 4; i++) {
17+
int A; cin >> A;
18+
mx = max(mx, ++cnt[A]);
19+
}
20+
21+
int ans = mx <= 2 ? 2 : (mx <= 3 ? 1 : 0);
22+
cout << ans << "\n";
23+
}
24+
}

‎Codechef/special_triplets.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
5+
#define long long long int
6+
7+
int main() {
8+
ios_base::sync_with_stdio(false);
9+
cin.tie(NULL);
10+
11+
int T; cin >> T;
12+
while (T--) {
13+
int N; cin >> N;
14+
15+
long ans = 0LL;
16+
for (int C = 1; C <= N; C++)
17+
for (int B = 2 * C; B <= N; B += C)
18+
ans += (N - C) / B + 1;
19+
20+
cout << ans << "\n";
21+
}
22+
}

0 commit comments

Comments
 (0)
Please sign in to comment.