Submission #464030

# Submission time Handle Problem Language Result Execution time Memory
464030 2021-08-12T09:34:33 Z CyberCow Rack (eJOI19_rack) C++17
100 / 100
22 ms 204 KB
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <cmath>
#include <map>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <iterator>
#include <stack>
using namespace std;
using ll = long long;
int a[2000000];
int b[2000000];
int erk = 1, n, mod = 1000000007;
ll k;
ll BinPow(ll a, int x)
{
    if (x == 0)
        return 1;
    if (x % 2 == 0)
    {
        return BinPow((a * a) % mod, x / 2);
    }
    return(a * BinPow(a, x - 1)) % mod;
}
int Bin = BinPow(2, mod - 2);
void rec(int p, ll qan, ll qan1, ll ind, ll erk)
{
    if (p == n)
    {
        cout << ind;
        exit(0);
    }
    if ((qan + 1) / 2 != (qan1 + 1) / 2)
    {
        rec(p + 1, (qan + 1) / 2, (qan1 + 1) / 2, (mod + ind - erk)%mod, (erk * Bin) % mod);
    }
    else
    {
        rec(p + 1, qan / 2, qan1 / 2, ind, (erk * Bin) % mod);
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int i, j, erk = 1;
    cin >> n >> k;
    for ( i = 0; i < n - 1; i++)
    {
        erk = (erk * 2) % mod;
    }
    rec(0, k, k - 1, (erk * 2)%mod, erk);
    return 0;
}

Compilation message

rack.cpp: In function 'int main()':
rack.cpp:51:12: warning: unused variable 'j' [-Wunused-variable]
   51 |     int i, j, erk = 1;
      |            ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 2 ms 204 KB Output is correct
15 Correct 22 ms 204 KB Output is correct