답안 #464529

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
464529 2021-08-13T11:02:57 Z Itamar Rack (eJOI19_rack) C++14
컴파일 오류
0 ms 0 KB
#include <iostream>
using namespace std;
#include <algorithm>
#include <vector>

long long y = pow(10, 9) + 7;

long  long po(long long a, long long b) {
    if (b == 0) {
        return 1;
    }
    vector<bool> vec;
    long long c = a;
    while (b > 1) {
        if (b % 2 == 1) {
            vec.push_back(0);
            b = b - 1;

        }
        else {
            vec.push_back(1);
            b = b / 2;

        }
    }

    reverse(vec.begin(), vec.end());
    int vec_size = vec.size();
    for (int i = 0; i < vec_size; i++) {
        if (vec[i] == 0) {
            a = (a * c) % y;
        }
        else {
            a = (a * a) % y;
        }
        return a;
    }
}

long long fun(long long n, long long k) {
    if (k == 1) {
        return 1;
    }
    
    if (k % 2 == 0) {
        long long x = fun(n - 1, k / 2);
        long long b = po(2, n - 1);
        return (x + b) % y;

    }
    else {
        long long x = fun(n - 1, k / 2 + 1);
        return x% y;
    }

}
int main()
{
    long long n, k;
    cin >> n;
    cin >> k;
    cout << fun(n, k);
}

Compilation message

rack.cpp:6:15: error: 'pow' was not declared in this scope
    6 | long long y = pow(10, 9) + 7;
      |               ^~~
rack.cpp: In function 'long long int po(long long int, long long int)':
rack.cpp:12:18: warning: control reaches end of non-void function [-Wreturn-type]
   12 |     vector<bool> vec;
      |                  ^~~