Submission #466174

# Submission time Handle Problem Language Result Execution time Memory
466174 2021-08-18T09:43:21 Z MKutayBozkurt Rack (eJOI19_rack) C++14
Compilation error
0 ms 0 KB
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

#define int long long
const int mod = 1e9 + 7;

int32_t main() {
  ios::sync_with_stdio(0); cin.tie(0);
  function<int(int, int)> power = [&](int a, int b) {
    int ans = 1;
    while (b) {
      if (b & 1) ans = ans * a % mod;
      a = a * a % mod;
      b /= 2;
      ans %= mod;
    }
    return ans % mod;
  };
  function<int(int, int)> f = [&](int n, int k) {
    if (n == 0ll) return 1ll;
    if (k & 1) {
      return f(n - 1, (k + 1) / 2);
    } else {
      return f(n - 1, k / 2) + power(2, n - 1) % mod;
    }
  };
  int n, k; cin >> n >> k;
  cout << f(n, k) << '\n';
}

Compilation message

rack.cpp: In function 'int32_t main()':
rack.cpp:11:3: error: 'function' was not declared in this scope
   11 |   function<int(int, int)> power = [&](int a, int b) {
      |   ^~~~~~~~
rack.cpp:4:1: note: 'std::function' is defined in header '<functional>'; did you forget to '#include <functional>'?
    3 | #include <algorithm>
  +++ |+#include <functional>
    4 | using namespace std;
rack.cpp:6:13: error: expected primary-expression before 'long'
    6 | #define int long long
      |             ^~~~
rack.cpp:11:12: note: in expansion of macro 'int'
   11 |   function<int(int, int)> power = [&](int a, int b) {
      |            ^~~
rack.cpp:6:13: error: expected primary-expression before 'long'
    6 | #define int long long
      |             ^~~~
rack.cpp:21:12: note: in expansion of macro 'int'
   21 |   function<int(int, int)> f = [&](int n, int k) {
      |            ^~~
rack.cpp:30:11: error: 'f' was not declared in this scope
   30 |   cout << f(n, k) << '\n';
      |           ^