Kaleido Kronos Cheers at i-Fest!
A cosmic shoutout to all the coders who rocked the FizzBuzz-Junior contest at i-Fest! Your code, like strokes on a digital canvas, is shaping the future of tech. In the dance of Fizz and Buzz, your brilliance shines. Congrats to the victors! May the spirit of Kaleido Kronos fuel your future coding adventures!
So, we're dealing with participants applying for either Fizzbuzz or Blind C. Let's represent the set of participants for Blind C as $$$S1$$$ and for Fizzbuzz as $$$S2$$$. Now, the participants who applied for either event form a set, let's call it $$$S$$$. The question boils down to finding the number of participants who applied for both events.
In the world of sets, there's this handy formula:
$$$[ N(A \cup B) = N(A) + N(B) - N(A \cap B) ]$$$
In our scenario, $$$N(A)$$$ is the number of participants for Blind C, $$$N(B)$$$ is for Fizzbuzz, and $$$N(A \cup B)$$$ is the total participants in both events. So, our answer would be the sum of participants in $$$S1$$$ and $$$S2$$$, minus the total participants in both sets. Clear as mud?
#include <stdio.h>
int main() {
// Total participants in both events (N(A ∪ B))
int totalParticipantsBothEvents;
scanf("%d", &totalParticipantsBothEvents);
// Number of participants for Fizzbuzz (N(B))
int participantsFizzbuzz;
scanf("%d", &participantsFizzbuzz);
// Number of participants for Blind C (N(A))
int participantsBlindC;
scanf("%d", &participantsBlindC);
// Calculate the number of participants who applied for both events (N(A ∩ B))
int participantsBothEvents = participantsBlindC + participantsFizzbuzz - totalParticipantsBothEvents;
printf("%d\n", participantsBothEvents);
return 0;
}
The task is to determine the minimum rotation needed to align a plane on the runway. While it might sound complex, the question essentially asks for the minimum angle between the plane and the $$$x$$$-axis. To calculate this angle, take the modulo of the angle by $$$360^\circ$$$ since the angle repeats its value after a full circle.
Now, adjust the angle accordingly to quadrants, Refer to the code below for detailed explaination.
That's the key to finding the answer. Easy, right?
#include <stdio.h>
int main() {
int angle;
scanf("%d", &angle);
// Take modulo to handle angle repetition after 360°
angle %= 360;
// Adjust the angle based on the quadrant
int minimumRotation;
if (angle >= 0 && angle < 90) {
minimumRotation = angle;
} else if (angle >= 90 && angle < 180) {
minimumRotation = 180 - angle;
} else if (angle >= 180 && angle < 270) {
minimumRotation = angle - 180;
} else {
minimumRotation = 360 - angle;
}
printf("%d\n", minimumRotation);
return 0;
}
Solution
#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
int arr[n];
int cnt_odd = 0;
for (int i = 0; i < n; i++) {
scanf("%d", &arr[i]);
if (arr[i] % 2 == 1) {
cnt_odd++;
}
}
if (cnt_odd % 2 == 0) {
printf("YES\n");
} else {
printf("NO\n");
}
return 0;
}
Solution
#include <stdio.h>
int main() {
int x;
scanf("%d", &x);
int v[32];
for (int i = 0; i < 32; i++) {
v[i] = (x >> i) & 1;
}
int a = 0, b = 0;
int flag = 0;
for (int i = 0; i < 32; i++) {
if (v[i] == 1) {
if (!flag) {
b = 1 << i;
flag = 1;
} else {
a += 1 << i;
}
}
}
if (a == 0 || b == 0) {
printf("-1\n");
} else {
printf("%d %d\n", a, b);
}
return 0;
}
Solution
#include <stdio.h>
#include <limits.h>
int gcd(int a, int b) {
while (b != 0) {
int temp = b;
b = a % b;
a = temp;
}
return a;
}
int max(int a, int b){
if(a>b){
return a;
}
else{
return b;
}
}
int main() {
int n;
scanf("%d", &n);
int arr[n];
for (int i = 0; i < n; i++) {
scanf("%d", &arr[i]);
}
int pre[n + 1];
int suf[n + 1];
for(int i=0; i<=n; i++){
pre[i]=0;
suf[i]=0;
}
for (int i = 1; i < n + 1; i++) {
pre[i] = gcd(pre[i - 1], arr[i - 1]);
}
for (int i = n - 1; i >= 0; i--) {
suf[i] = gcd(suf[i + 1], arr[i]);
}
int ans = INT_MAX;
for (int i = 1; i < n; i++) {
if (pre[i] == suf[i]) {
ans = (ans < (max(i, n - (i + 1)))) ? ans : (max(i, n - (i + 1)));
}
}
if (ans == INT_MAX) {
printf("-1\n");
return 0;
}
printf("%d\n", ans + 1);
return 0;
}