| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1344953 | quan606303 | Intercastellar (JOI22_ho_t1) | C++20 | 38 ms | 5360 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;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
