a tiny kattis grind
This commit is contained in:
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.
Reference in New Issue
Block a user