답안 #1075768

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1075768 2024-08-26T09:05:58 Z matthew Rack (eJOI19_rack) C++17
40 / 100
1 ms 348 KB
#include <stdio.h>

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 < n; i++) {
    if((k >> i) & 1) {
      res = (res + lgput(2, n - 1 - i)) % MOD;
    }
  }
  printf("%d\n", res + 1);

  return 0;
}

Compilation message

rack.cpp: In function 'int main()':
rack.cpp:25:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |   scanf("%d%lld", &n, &k);
      |   ~~~~~^~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 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
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 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 1 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 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 1 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Incorrect 0 ms 348 KB Output isn't correct
13 Halted 0 ms 0 KB -