Submission #1211246

#TimeUsernameProblemLanguageResultExecution timeMemory
1211246nguynRack (eJOI19_rack)C++20
40 / 100
0 ms328 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define ll long long #define F first #define S second #define pb push_back #define pii pair<int,int> const int N = 1e6 + 5; const int mod = 1e9 + 7; int n, k; int pw[N]; void add(int &x, int y) { x += y; if (x >= mod) x -= mod; } signed main(){ ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0) ; if (fopen("INP.INP" ,"r")) { freopen("INP.INP" ,"r" , stdin) ; freopen("OUT.OUT" , "w" , stdout) ; } cin >> n >> k; // if (n <= 20) { // vector<int> cur; // cur.pb(1); // for (int i = (1 << (n - 1)); i >= 1; i >>= 1) { // int sz = cur.size(); // for (int j = 0; j < sz; j++) { // cur.pb(cur[j] + i); // } // } // // for (int i : cur) { // // cout << i << ' '; // // } // cout << cur[k - 1] << '\n'; // return 0; // } pw[0] = 1; for (int i = 1; i <= n; i++) { pw[i] = pw[i - 1] + pw[i - 1]; if (pw[i] >= mod) pw[i] -= mod; } int res = 0; for (int i = min(n, 60ll); i >= 0; i--) { if (k > (1 << i)) { int t = i + 1; // cout << t << ' ' << pw[n - t] << '\n'; add(res, pw[n - t]); k -= (1 << i); } } cout << res + 1; }

Compilation message (stderr)

rack.cpp: In function 'int main()':
rack.cpp:26:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |         freopen("INP.INP" ,"r" , stdin) ;
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
rack.cpp:27:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |         freopen("OUT.OUT" , "w" , stdout) ;
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...