Bottle Opening

Question

Solution

Idea

Time Complexity: O(n)O(n)

This problem is also a give-away question. The key point is to convert it using computational thinking. The implementation is shown in the following code part.

Code

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

int main()
{
  int n, k;
  scanf("%d \n %d", &n, &k);
  if (k >= n)
  {
    printf("impossible\n");
  }
  else
  {
    for (int i = 1; i <= k; i += 1)
    {
      printf("open %d using %d\n", i, i + 1);
    }
  }
}

Last updated