Submission #444455

# Submission time Handle Problem Language Result Execution time Memory
444455 2021-07-14T06:00:55 Z idas Rack (eJOI19_rack) C++17
0 / 100
1 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);
}

const int N=1e6+10;

ll n, k, pw[N];

int main()
{
    setIO();
    cin >> n >> k;
    pw[0]=1;
    FOR(i, 1, n+1) pw[i]=pw[i-1]*2%MOD;
    ll fourth=(k-1)/4, liek=(k-1)%4;
    ll val=(fourth>=1?pw[n-2-fourth]:0);
    if(liek==1){
        val=(val+pw[2, n-1])%MOD;
    }
    else if(liek==2){
        val=(val+pw[2, n-2])%MOD;
    }
    else if(liek==3){
        val=(val+pw[2, n-2]%MOD+pw[2, n-1])%MOD;
    }
    cout << (val+1LL)%MOD;
}

Compilation message

rack.cpp: In function 'int main()':
rack.cpp:48:21: warning: left operand of comma operator has no effect [-Wunused-value]
   48 |         val=(val+pw[2, n-1])%MOD;
      |                     ^
rack.cpp:51:21: warning: left operand of comma operator has no effect [-Wunused-value]
   51 |         val=(val+pw[2, n-2])%MOD;
      |                     ^
rack.cpp:54:21: warning: left operand of comma operator has no effect [-Wunused-value]
   54 |         val=(val+pw[2, n-2]%MOD+pw[2, n-1])%MOD;
      |                     ^
rack.cpp:54:36: warning: left operand of comma operator has no effect [-Wunused-value]
   54 |         val=(val+pw[2, n-2]%MOD+pw[2, n-1])%MOD;
      |                                    ^
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 1 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 1 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 1 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 -