답안 #464117

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
464117 2021-08-12T12:03:14 Z Sench2006 Rack (eJOI19_rack) C++14
0 / 100
2 ms 332 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ar array

#define f first
#define s second
#define mpr make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

#define FOR(i, a, b) for(auto i = a; i < b; i++)
#define FORD(i, a, b) for(auto i = a - 1; i >= b; i--)
#define trav(x, v) for(auto x : v)

#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fileio freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

// --------------- SOLUTION --------------- //

const ll MOD = 1e9+7;
ll n, k;
vector <ll> x;
 
ll getAns(ll n, ll k) {
    if (n == 0) {
        return 1;
    } if (k % 2LL) { 
        return getAns(n - 1LL, (k + 1LL) / 2LL);
    } else {
        return (getAns(n - 1LL, k / 2LL) + x[n - 1]) % MOD; 
    }
}

void solve() {
    cin >> n >> k;
    x = vector<ll> (n, 1);
    FOR(i, 1, n) {
        x[i] = (x[i - 1] * 2) % MOD;
    }
    cout << getAns(n, k) << "\n";
}

int main() {
    fastio;
    fileio;
    int tests = 1;
    // cin >> tests;
    while (tests--) {
        solve();
    }

    return 0;
}

Compilation message

rack.cpp: In function 'int main()':
rack.cpp:20:23: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 | #define fileio freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
      |                ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
rack.cpp:49:5: note: in expansion of macro 'fileio'
   49 |     fileio;
      |     ^~~~~~
rack.cpp:20:57: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 | #define fileio freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
      |                                                  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
rack.cpp:49:5: note: in expansion of macro 'fileio'
   49 |     fileio;
      |     ^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -