제출 #1344953

#제출 시각아이디문제언어결과실행 시간메모리
1344953quan606303Intercastellar (JOI22_ho_t1)C++20
100 / 100
38 ms5360 KiB
/*idea : 
- Moi lan cat doi mot so chan thanh hai so giong nhau.
- Ket qua cuoi cung cua mot so a = L * 2^k la 2^k so le L.
- Su dung mang cong don de luu so luong mieng banh va chat nhi phan de tra loi truy van.
*/
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define INTMAX INT_MAX
#define INTMIN INT_MIN
#define LONGMAX LLONG_MAX
#define LONGMIN LLONG_MIN
#define fi first
#define se second
#define memfull(a,b) memset(a,b,sizeof(a));
#define endl '\n'
#define TASK "TIRAMISSU"
#define file() if (fopen(TASK".inp","r")){freopen(TASK".inp","r",stdin); freopen(TASK".out","w",stdout);}
using namespace std;
const int MOD=1e9+7;

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    file();
    
    int n;
    
    cin >> n;

    vector<int> L(n + 1);
    vector<int> P(n + 1, 0);
    
    for (int i = 1; i <= n; i++) {
        int a;
        cin >> a;
        int count = 1;
        while (a % 2 == 0) {
            count *= 2;
            a /= 2;
        }
        L[i] = a;
        P[i] = P[i - 1] + count;
    }
    
    int q;
    cin >> q;
    while (q--) {
        int x;
        cin >> x;
        int pos = lower_bound(P.begin() + 1, P.end(), x) - P.begin();
        cout << L[pos] << endl;
    }
    
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'int32_t main()':
Main.cpp:18:50: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 | #define file() if (fopen(TASK".inp","r")){freopen(TASK".inp","r",stdin); freopen(TASK".out","w",stdout);}
      |                                           ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
Main.cpp:27:5: note: in expansion of macro 'file'
   27 |     file();
      |     ^~~~
Main.cpp:18:81: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 | #define file() if (fopen(TASK".inp","r")){freopen(TASK".inp","r",stdin); freopen(TASK".out","w",stdout);}
      |                                                                          ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:27:5: note: in expansion of macro 'file'
   27 |     file();
      |     ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...