답안 #641293

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
641293 2022-09-16T10:10:59 Z Yelarys Rack (eJOI19_rack) C++17
100 / 100
2 ms 1236 KB
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
#define pb push_back    
#define F first
#define S second
#define mp make_pair
#define sz(x) (int)x.size()
#define speed ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
#define rep(i, a, b) for(int i = a; i < b; i++)
#define pf push_front
#define pb push_back
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vi vector<int>
#define vll vector<long long>
#define vpii vector<pair<int, int>>
#define vpll vector<pair<long long, long long>>
#define fl fflush(stdout)
const ll INF = INT_MAX;
const int N = (int)1e5 + 20;
const ll mod = (ll)1e9 + 7;
const int P = 31;
ll binpow(ll a, int n){if(n == 0)return 1;if(n == 1)return a;ll r = binpow(a, n / 2) % mod;if(n % 2)return (((r * r) % mod) * a) % mod;return(r * r) % mod;}
void setIO() {
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
}
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
bool ans[10 * N];
void yela(){
    ll n, k;
    cin >> n >> k;
    k--;
    for(int i = 0; i < min(62LL, n); i++){
        ans[i] = k & (1LL << i);
    }
    reverse(ans, ans + n);
    ll sum = 0;
    for(int i = 0; i < n; i++){
        if(ans[i]){
            sum += binpow(2, i);
            sum %= mod;
        }
    }
    sum++;
    cout << sum % mod;
}
int main(){
    speed;
    int T = 1;
    //cin >> T;
	for(int i = 1; i <= T; i++){
        yela();
	}
}

Compilation message

rack.cpp: In function 'void setIO()':
rack.cpp:29:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |  freopen("in.txt", "r", stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
rack.cpp:30:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |  freopen("out.txt", "w", stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 340 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
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 340 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 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 2 ms 1236 KB Output is correct