Submission #464108

#TimeUsernameProblemLanguageResultExecution timeMemory
464108Sench2006Rack (eJOI19_rack)C++14
Compilation error
0 ms0 KiB
#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 int MOD = 1e9+7; int n, k; int getAns(int n, int k) { if (n == 0) return 1; if (k % 2 == 1) return getAns(n - 1, (k + 1) / 2); if (k % 2 == 0) return (getAns(n - 1, k / 2) + (x[n - 1]) % MOD)); } void solve() { cin >> n >> k; x[0] = 1; FOR(i, 1, n + 1) { 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 (stderr)

rack.cpp: In function 'int getAns(int, int)':
rack.cpp:30:51: error: 'x' was not declared in this scope
   30 |   if (k % 2 == 0) return (getAns(n - 1, k / 2) + (x[n - 1]) % MOD));
      |                                                   ^
rack.cpp:30:67: error: expected ';' before ')' token
   30 |   if (k % 2 == 0) return (getAns(n - 1, k / 2) + (x[n - 1]) % MOD));
      |                                                                   ^
      |                                                                   ;
rack.cpp:30:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   30 |   if (k % 2 == 0) return (getAns(n - 1, k / 2) + (x[n - 1]) % MOD));
      |   ^~
rack.cpp:30:67: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   30 |   if (k % 2 == 0) return (getAns(n - 1, k / 2) + (x[n - 1]) % MOD));
      |                                                                   ^
rack.cpp:30:67: error: expected primary-expression before ')' token
rack.cpp: In function 'void solve()':
rack.cpp:35:4: error: 'x' was not declared in this scope
   35 |    x[0] = 1;
      |    ^