Submission #444445

# Submission time Handle Problem Language Result Execution time Memory
444445 2021-07-14T05:34:03 Z idas Rack (eJOI19_rack) C++11
0 / 100
0 ms 204 KB
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i = (begin); i < (end); i++)
#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define SZ(x) ((int)((x).size()))
#define LE(vec) vec[vec.size()-1]
#define TSTS int t; cin >> t; while(t--)solve()

const int INF = 1e9;
const long long LINF = 1e18;
const long double PI = asin(1)*2;
const int MOD = 1e9+7;

using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef map<int, int> mii;
typedef long long ll;
typedef long double ld;

void setIO()
{
    FAST_IO;
}

void setIO (string s) {
    setIO();
 	freopen((s+".in").c_str(),"r",stdin);
 	freopen((s+".out").c_str(),"w",stdout);
}

ll n, k;

ll pwr(ll a, ll b)
{
    if(b==0) return 1;
    if(b==1) return a;
    ll ret=pwr(a, b/2);
    if(b&1) return ret*ret%MOD*a%MOD;
    return ret*ret%MOD;
}

int main()
{
    setIO();
    cin >> n >> k;
    ll fourth=(k-1)/4, liek=(k-1)%4;
    ll val=(fourth>=1?pwr(2, n-2-fourth):0);
    if(liek==0){
        ///nothing;
    }
    else if(liek==1){
        val=(val+pwr(2, n-1))%MOD;
    }
    else if(liek==2){
        val=(val+pwr(2, n-2))%MOD;
    }
    else{
        val=(val+pwr(2, n-2)%MOD+pwr(2, n-1))%MOD;
    }
    cout << val+1;
}

Compilation message

rack.cpp: In function 'void setIO(std::string)':
rack.cpp:31:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |   freopen((s+".in").c_str(),"r",stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rack.cpp:32:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |   freopen((s+".out").c_str(),"w",stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 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 Incorrect 0 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 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 Incorrect 0 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 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 Incorrect 0 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -