Hi!
We all know how important it is to choose a university.
But I have a problem with that.
please help me with choosing a university!
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 3690 |
2 | jiangly | 3647 |
3 | Benq | 3581 |
4 | orzdevinwang | 3570 |
5 | Geothermal | 3569 |
5 | cnnfls_csy | 3569 |
7 | Radewoosh | 3509 |
8 | ecnerwala | 3486 |
9 | jqdai0815 | 3474 |
10 | gyh20 | 3447 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | maomao90 | 174 |
2 | awoo | 164 |
3 | adamant | 163 |
4 | TheScrasse | 159 |
5 | nor | 157 |
6 | maroonrk | 156 |
7 | -is-this-fft- | 152 |
8 | Petr | 146 |
8 | orz | 146 |
10 | BledDest | 145 |
Hi!
We all know how important it is to choose a university.
But I have a problem with that.
please help me with choosing a university!
how many words per minute you type?
Hello Codeforces!
Today I was solving one problem from codeforces edu
#include<bits/stdc++.h>
#define ll long long
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
struct segtree {
vector<int> tree;
int size;
const int zero = 0;
void init(int n) {
size = 1;
while (size < n)size *= 2;
tree.assign(size * 2 - 1, 0);
}
void build(vector<int> &a, int x, int lx, int rx) {
if (rx - lx == 1) {
if (lx < a.size())
tree[x] = a[lx];
} else {
int mid = (lx + rx) >> 1;
build(a, 2 * x + 1, lx, mid);
build(a, 2 * x + 2, mid, rx);
tree[x] = tree[2 * x + 1] + tree[2 * x + 2];
}
}
void build(vector<int> &a) {
init(a.size());
build(a, 0, 0, size);
}
void set(int i, int v, int x, int lx, int rx) {
if (rx - lx == 1) {
tree[x] = v;
return;
}
int mid = (lx + rx) >> 1;
if (i < mid)set(i, v, 2 * x + 1, lx, mid);
else set(i, v, 2 * x + 2, mid, rx);
tree[x] = tree[2 * x + 1] + tree[2 * x + 2];
}
void set(int i, int v) {
set(i, v, 0, 0, size);
}
int find(int k, int x, int lx, int rx) {
if (rx - lx == 1) {
return lx;
}
int m = (lx + rx) >> 1;
if (k < tree[2 * x + 1])return find(k, 2 * x + 1, lx, m);
else return find(k - tree[2 * x + 1], 2 * x + 2, m, rx);
}
int find(int k) {
find(k, 0, 0, size);
}
};
int32_t main() {
fast
int n, q;
cin >> n >> q;
vector<int> a(n);
for (auto &i: a)cin >> i;
segtree st;
st.build(a);
while (q--) {
int c;
cin >> c;
if (c == 1) {
int i;
cin >> i;
st.set(i, 1 - a[i]);
a[i] = 1 - a[i];
} else {
int k;
cin >> k;
cout << st.find(k) << endl;
}
}
return 0;
}
/*
* @Nargulyev
*/
Can someone tell me how I can solve this problem? (Sorry for my English)
Thanks!
Привет всем!
Сегодня решая задачу на infromatics-e столкнулся с проблемой.
Я конечно пробывал решить задачу, но в итоге:
#include<bits/stdc++.h>
#define ll long long
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int k;
int mod(string s) {
int r = 0;
for (int i = 0; i < s.length(); ++i) {
r *= 10;
r += s[i] — '0';
r %= k;
}
return r;
}
int32_t main() {
fast
string s;
cin >> s;
cin >> k;
int d;
cin >> d;
vector<int> dig(d);
for (auto &i: dig) {
cin >> i;
}
int p = mod(s);
if (p == 0) {
cout << s << endl;
return 0;
}
sort(dig.begin(), dig.end());
queue<string> q;
int cnt = 0;
q.push(s);
while (!q.empty()) {
auto t = q.front();
if (mod(t) == 0) {
cout << t;
return 0;
}
for (auto i: dig) {
string c = t;
c += char(i + 48);
q.push(c);
}
++cnt;
if ((cnt + d - 1) / d >= 10000 * d)
break;
q.pop();
}
cout << -1;
return 0;
}
/*
* @Nargulyev
*/
помогите пожалуйста!
+ It's my birthday today
Я смотрю и вижу как другие становятся зелёными, а я всё ещё новичок. Как мне изучить множество алгоритмов, математику, геометрию... Пожалуйста дайте советы как мне стать Учеником.
Название |
---|