Submission #637513

# Submission time Handle Problem Language Result Execution time Memory
637513 2022-09-02T10:51:44 Z ksu2009en Rack (eJOI19_rack) C++17
40 / 100
0 ms 212 KB
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <bitset>
#include <cstring>

using namespace std;
typedef long long ll;

ll power[1000007];

ll solve(ll pos, ll pow){
    if(pos == 1 || pow < 0)
        return 1;
    
    ll res = 0;
    
    if(pos % 2 != 0)
       res = solve((pos + 1) / 2, pow - 1) % (ll)(1e9 + 7);
    else
        res = solve((pos + 1) / 2, pow - 1);
    
    
    //cout << pos << ' ' << pow << ' ' << res << endl;
    
    return res + (pos % 2 == 0 ? power[pow] : 0);
}

int main(){
    ll n, k;
    cin >> n >> k;
    
    power[0] = 1;
    
    for(int i = 1; i <= n; i++)
        power[i] = (power[i - 1] * 2) % (ll)(1e9 + 7 );
    
    cout << solve(k, n - 1) << endl;
    
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Incorrect 0 ms 212 KB Output isn't correct
12 Halted 0 ms 0 KB -