답안 #564831

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
564831 2022-05-19T18:46:17 Z mircea_007 Rack (eJOI19_rack) C++17
100 / 100
1 ms 328 KB
// This program was written on 19.05.2022
// for problem rack
// by Mircea Rebengiuc

#include <stdio.h>

#define MOD 1000000007
#define INV2 500000004LL

int lgput( int base, int exp ){
  int retval = 1;
  
  while( exp ){
    if( exp & 1 )
      retval = ((long long)retval) * base % MOD;
    
    base = ((long long)base) * base % MOD;
    exp >>= 1;
  }
  
  return retval;
}

int main(){
  int n, ans = 1, p2 = 1;
  long long k;
  
  scanf( "%d%lld", &n, &k );
  k--;
  
  p2 = lgput( 2, n - 1 );
  
  while( k ){
    ans += p2 * (k & 1);
    ans %= MOD;

    p2 = (INV2 * p2) % MOD;
    k >>= 1;
  }
  
  printf( "%d\n", ans );
  
  return 0;
}

Compilation message

rack.cpp: In function 'int main()':
rack.cpp:28:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |   scanf( "%d%lld", &n, &k );
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 328 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 284 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 284 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 328 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 284 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 284 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 284 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 284 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 328 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 284 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 284 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 284 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 284 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 284 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 280 KB Output is correct