a tiny kattis grind
This commit is contained in:
parent
6d10ae8c7e
commit
692af44603
1
kattis/problems/01_12_23/kikiboba/4.in
Normal file
1
kattis/problems/01_12_23/kikiboba/4.in
Normal file
@ -0,0 +1 @@
|
||||
ljus
|
26
kattis/problems/01_12_23/kikiboba/main.c
Normal file
26
kattis/problems/01_12_23/kikiboba/main.c
Normal file
@ -0,0 +1,26 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int b = 0, k = 0;
|
||||
char c;
|
||||
while ((c = getchar()) != EOF) {
|
||||
if (c == 'b') {
|
||||
b++;
|
||||
}
|
||||
if (c == 'k') {
|
||||
k++;
|
||||
}
|
||||
|
||||
}
|
||||
if (b > k) {
|
||||
printf("boba\n");
|
||||
} else if (k > b) {
|
||||
printf("kiki\n");
|
||||
} else if (k == 0 && b == 0) {
|
||||
printf("none\n");
|
||||
} else if (k == b) {
|
||||
printf("boki\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
17
kattis/problems/01_12_23/kikiboba/main.c.orig
Normal file
17
kattis/problems/01_12_23/kikiboba/main.c.orig
Normal file
@ -0,0 +1,17 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int b = 0, k = 0;
|
||||
char c;
|
||||
while ((c = getchar()) != EOF) {
|
||||
if (c == 'b') b++;
|
||||
if (c == 'k') k++;
|
||||
|
||||
}
|
||||
if (b > k) printf("boba\n");
|
||||
if (k > b) printf("kiki\n");
|
||||
if (k == 0 && b == 0) printf("none\n");
|
||||
if (k == b) printf("boki\n");
|
||||
return 0;
|
||||
}
|
BIN
kattis/problems/01_12_23/kikiboba/program
Executable file
BIN
kattis/problems/01_12_23/kikiboba/program
Executable file
Binary file not shown.
1
kattis/problems/01_12_23/ladder/1.in
Normal file
1
kattis/problems/01_12_23/ladder/1.in
Normal file
@ -0,0 +1 @@
|
||||
500 70
|
15
kattis/problems/01_12_23/ladder/main.c
Normal file
15
kattis/problems/01_12_23/ladder/main.c
Normal file
@ -0,0 +1,15 @@
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#define PI 3.14159265358979323846
|
||||
|
||||
int main() {
|
||||
int wall_height, max_angle;
|
||||
|
||||
scanf("%d %d", &wall_height, &max_angle);
|
||||
double max_angle_radians = max_angle * PI / 180.0;
|
||||
double ladder_length = wall_height / sin(max_angle_radians);
|
||||
int rounded_length = (int)ceil(ladder_length);
|
||||
printf("%d\n", rounded_length);
|
||||
|
||||
return 0;
|
||||
}
|
23
kattis/problems/01_12_23/ladder/main.c.orig
Normal file
23
kattis/problems/01_12_23/ladder/main.c.orig
Normal file
@ -0,0 +1,23 @@
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
int main() {
|
||||
int wall_height, max_angle;
|
||||
|
||||
// Input values
|
||||
scanf("%d %d", &wall_height, &max_angle);
|
||||
|
||||
// Convert max_angle from degrees to radians
|
||||
double max_angle_radians = max_angle * M_PI / 180.0;
|
||||
|
||||
// Calculate ladder length
|
||||
double ladder_length = wall_height / sin(max_angle_radians);
|
||||
|
||||
// Round up to the nearest integer
|
||||
int rounded_length = (int)ceil(ladder_length);
|
||||
|
||||
// Print the result
|
||||
printf("%d\n", rounded_length);
|
||||
|
||||
return 0;
|
||||
}
|
BIN
kattis/problems/01_12_23/ladder/program
Executable file
BIN
kattis/problems/01_12_23/ladder/program
Executable file
Binary file not shown.
32
kattis/problems/01_12_23/stokigalistor.c
Normal file
32
kattis/problems/01_12_23/stokigalistor.c
Normal file
@ -0,0 +1,32 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int cmpfunc(const void *a, const void *b) {
|
||||
return (*(int *)a - *(int *)b);
|
||||
}
|
||||
int main(int argc, char **argv) {
|
||||
int n;
|
||||
int arr[1000];
|
||||
|
||||
scanf("%d", &n);
|
||||
for (int i = 0; i < n; i++) {
|
||||
scanf("%d", &arr[i]);
|
||||
}
|
||||
|
||||
int sorted[1000];
|
||||
for (int i = 0; i < n; i++) {
|
||||
sorted[i] = arr[i];
|
||||
}
|
||||
|
||||
qsort(sorted, n, sizeof(int), cmpfunc);
|
||||
|
||||
int wrong = 0;
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (arr[i] != sorted[i]) {
|
||||
wrong += 1;
|
||||
}
|
||||
}
|
||||
|
||||
printf("%d\n", wrong);
|
||||
return 0;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user