CSES - Datatähti 2017 alku - Results
Submission details
Task:Bittijono
Sender:vuolen
Submission time:2016-10-06 20:27:39 +0300
Language:C++
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'uint8_t get_bit(uint64_t)':
input/code.cpp:9:17: error: 'pow' was not declared in this scope
     n = pow(n, 2);
                 ^
input/code.cpp: In function 'int main()':
input/code.cpp:17:17: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'uint64_t* {aka long unsigned int*}' [-Wformat=]
   scanf("%d", &k);
                 ^
input/code.cpp:17:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &k);
                  ^

Code

#include <stdio.h>
#include <stdint.h>

uint8_t get_bit(uint64_t k) {
  if (k == 1)
    return 0;
  uint8_t n = 2;
  while (n < k) {
    n = pow(n, 2);
  }

  return !get_bit(k - n / 2);
}

int main(void) {
  uint64_t k;
  scanf("%d", &k);
  get_bit(k);
}