Submission #1214356

#TimeUsernameProblemLanguageResultExecution timeMemory
1214356badge881Rack (eJOI19_rack)C++20
100 / 100
7 ms8004 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; const int MOD = 1e9 + 7; const int MAX_N = 1e6; ll pot[MAX_N]; int solve(int n, ll k) { if (n == 0) return 1LL; if (k % 2 == 1) return solve(n - 1, (k + 1) / 2); int res = pot[n - 1] + solve(n - 1, k / 2); if (res >= MOD) res -= MOD; return res; } int main() { int n; ll k; scanf("%d %lld", &n, &k); pot[0] = 1; for (int i = 1; i < n; i++) { pot[i] = 2 * pot[i - 1]; if (pot[i] >= MOD) pot[i] -= MOD; } printf("%d\n", solve(n, k)); return 0; }

Compilation message (stderr)

rack.cpp: In function 'int main()':
rack.cpp:28:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |     scanf("%d %lld", &n, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...