Betting

Question

Solution

Idea

Time Complexity: O(1)O(1)

This a give-away question. The soul is to find the maths relation between the input and the answer. And this relation is shown in the code below.

Code

https://github.com/mendax1234/Coding-Problems/blob/main/kattis/betting/betting.c
#include <stdio.h>

int main()
{
  int percent;
  scanf("%d", &percent);
  double option1 = (double)(100 - percent) / (double)percent;
  double option2 = (double)percent / (double)(100 - percent);
  printf("%lf\n", (double)1 + option1);
  printf("%lf\n", (double)1 + option2);
}

Last updated