Submission #438661

# Submission time Handle Problem Language Result Execution time Memory
438661 2021-06-28T11:45:03 Z raid Rack (eJOI19_rack) C++17
100 / 100
13 ms 7992 KB
#include <iostream>
#include <vector>

using namespace std;

const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 1;

vector<int> db;
int pmod[MAXN];

int main() {
  int n;
  long long k;

  cin >> n >> k;
  --k;
  while ( k ) {
	db.push_back( k & 1 );
	k >>= 1;
  }
  while ( db.size() != n ) {
    db.push_back( 0 );
  }
  pmod[0] = 1;
  for ( int i = 1; i <= n; ++i ) {
	pmod[i] = (pmod[i - 1] * 2) % MOD;
  }
  long long res = 0;
  for ( int i = 0; i < n; ++i ) {
	if ( db[i] ) {
 	  res = (res + pmod[n - i - 1]) % MOD;
    }
  }
  cout << (res + 1) % MOD;
  return 0;
}

Compilation message

rack.cpp: In function 'int main()':
rack.cpp:22:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   22 |   while ( db.size() != n ) {
      |           ~~~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 2 ms 840 KB Output is correct
15 Correct 13 ms 7992 KB Output is correct