Submission #724941

# Submission time Handle Problem Language Result Execution time Memory
724941 2023-04-16T11:07:10 Z MercubytheFirst Rack (eJOI19_rack) C++14
40 / 100
1 ms 320 KB
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<climits>
#include<numeric>
#include<queue>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include<string.h>
#include<cmath>
#include<stack>
#define int uint64_t
using namespace std;
const int mod = 1e9 + 7;

int cdiv(int a, int b){
    return (a + b - 1ll) / b;
}

int bpow(int a, int b){
    if(a == 1 or b == 0)return 1;
    if(a == 0)return 0; // watch out for 0^0
    int ans = 1;
    a %= mod;
    while(b > 0){
        if(b&1)ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans;
} 

int inv(int x){
    return bpow(x, mod-2);
}


signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n, k;
    cin >> n >> k;
    int ans = 1,
        add = bpow(2, n-1), 
        kcpy = k,
        inv2 = inv(2);
    while(k > 1){
        if(!(k&1))ans += add;
        add = add * inv2 % mod;
        k = cdiv(k, 2);
    }
    cout << ans << endl;
}

Compilation message

rack.cpp: In function 'int main()':
rack.cpp:47:9: warning: unused variable 'kcpy' [-Wunused-variable]
   47 |         kcpy = k,
      |         ^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 320 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 320 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Incorrect 1 ms 212 KB Output isn't correct
12 Halted 0 ms 0 KB -