Submission #1075796

# Submission time Handle Problem Language Result Execution time Memory
1075796 2024-08-26T09:13:04 Z matthew Rack (eJOI19_rack) C++17
100 / 100
1 ms 604 KB
#include <stdio.h>
#include <algorithm>

const int MOD = 1'000'000'007;

int lgput(int a, int b) {
  int res = 1;
  while(b > 0) {
    if(b & 1) {
      res = (res * (long long)a) % MOD;
    }
    a = (a * (long long)a) % MOD;
    b /= 2;
  }
  return res;
}

int main() {
  #ifdef LOCAL
freopen("input.txt", "r", stdin);
  #endif

  int n, i, res;
  long long k;

  scanf("%d%lld", &n, &k);
  k--;
  res = 0;
  for(i = 0; i < std::min(n, 61); i++) {
    if((k >> i) & 1) {
      res = (res + lgput(2, n - 1 - i)) % MOD;
    }
  }
  printf("%d\n", (res + 1) % MOD);

  return 0;
}

Compilation message

rack.cpp: In function 'int main()':
rack.cpp:26:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |   scanf("%d%lld", &n, &k);
      |   ~~~~~^~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 416 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 416 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct