a tiny kattis grind

This commit is contained in:
2023-12-01 14:08:03 +01:00
parent 6d10ae8c7e
commit 692af44603
9 changed files with 115 additions and 0 deletions

View File

@ -0,0 +1 @@
500 70

View 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;
}

View 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;
}

Binary file not shown.