Search is not available for this dataset
name stringlengths 2 112 | description stringlengths 29 13k | source int64 1 7 | difficulty int64 0 25 | solution stringlengths 7 983k | language stringclasses 4
values |
|---|---|---|---|---|---|
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
int reader_pt = 1048576, reader_last;
char reader_buf[1048576];
int reader_nonneg_int() {
int r;
for (;;) {
if (reader_pt == 1048576)
reader_pt = 0,
reader_last = fread(reader_buf, sizeof(char), 1048576, stdin);
if (('0' <= (reader_buf[reader_pt]) &&... | CPP |
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
int n;
pair<int, int> a[300005];
set<int> s;
long double ans;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for (int i = 0; i < n; ++i) {
cin >> a[i].first;
a[i].second = i + 1;
}
sort(a, a + n);
reverse(a, a + n);
s.insert(0);
s... | CPP |
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
long long n, pre[((long long)301 * 1000)], nex[((long long)301 * 1000)];
pair<long long, long long> a[((long long)301 * 1000)];
set<long long> s;
long double ans;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for (int i = 0; i < n; i++)
cin >>... | CPP |
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
long double p[300300];
int n;
pair<int, int> b[300300];
void pre(void) {
p[0] = 1.0;
for (int i = 1; i < 300300; ++i) p[i] = p[i - 1] / 2;
}
struct node {
long double l, r;
int c;
} t[4 * 300300], one{0.5, 1.0, 1}, zero{1.0, 1.0, 0};
node comb(const node &l, const n... | CPP |
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
inline void smin(T &a, U b) {
if (a > b) a = b;
}
template <typename T, typename U>
inline void smax(T &a, U b) {
if (a < b) a = b;
}
template <class T>
inline void gn(T &first) {
char c, sg = 0;
while (c = getchar(), (c > '9' || c ... | CPP |
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
struct SegmentTreeDivideRange {
int size;
int treeSize;
vector<double> SUM;
vector<int> LAZY;
SegmentTreeDivideRange(int sz) {
size = sz;
treeSize = 4 * sz;
SUM.resize(treeSize);
LAZY.resize(treeSize);
}
void push(int x, int l, int r) {
if ... | CPP |
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
int n, w[1000010], b[1000010], nxt[1000010], pre[1000010];
double ans;
bool cmp(int x, int y) {
if (w[x] == w[y]) {
return x < y;
} else {
return w[x] < w[y];
}
}
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%d", &w[i]);
b[i]... | CPP |
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
using namespace ::std;
const long long maxn = 3e5 + 500;
const long long inf = 2e9;
long long a[maxn];
pair<long long, long long> b[maxn];
set<long long> st;
long long nxt[maxn];
long long pre[maxn];
void update(long long p) {
set<long long>::iterator itnxt = st.lower_bound(p);
set<long lon... | CPP |
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
#pragma comment(linker, "/STACK:60777216")
using namespace std;
int n;
int b[333333];
vector<pair<int, int> > t;
int rv[333333];
struct Node {
Node *lf;
Node *rg;
int l, r;
int mx;
Node() {
lf = rg = 0;
mx = 0;
}
};
Node *root;
Node *buildTree(int from, int to) {
Node *res... | CPP |
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
double x, y, z, s;
int n, a, b, c, v[300010], p[300010], l[300010], r[300010];
bool cmp(int x, int y) { return v[x] < v[y]; }
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++)
scanf("%d", &v[i]), l[i] = i - 1, r[i] = i + 1, p[i] = i;
sort(p + 1, p + n + 1... | CPP |
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
int N;
int a[300010];
vector<pair<int, int> > v;
set<int> s;
double get_coef(int x) {
int i, prev, cnt;
double two, c1 = 0.0, c2 = 0.0;
s.insert(x);
set<int>::iterator itr = s.find(x);
two = 1.0;
cnt = 0;
prev = x;
while (cnt < 50) {
itr--;
int y = (... | CPP |
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MAXN = 300010;
const int TINY = 1e-13;
int N;
double b[MAXN];
pair<double, int> first[MAXN];
const int MAXS = 30;
int Ls, Rs;
int L[MAXS], R[MAXS];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout << setprecision... | CPP |
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
template <class T>
inline void umax(T &a, T b) {
if (a < b) a = b;
}
template <class T>
inline void umin(T &a, T b) {
if (a > b) a = b;
}
template <class T>
inline T abs(T a) {
return a > 0 ? a : -a;
}
template <class T>
inline T gcd(T a, T b) {
return __gcd(a, b);
... | CPP |
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
template <class T>
inline void chkmin(T &a, T b) {
if (a > b) a = b;
}
template <class T>
inline void chkmax(T &a, T b) {
if (a < b) a = b;
}
int N, a[310000];
pair<int, int> p[310000];
set<int> st;
double calc(int u) {
double c1, c2, wei;
int cnt, pre;
set<int>::... | CPP |
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
int N;
const int NMax = 300005;
const int MaxS = 30;
double Array[NMax];
double ans;
int id[NMax], L[NMax], R[NMax];
inline bool cmp(int a, int b) { return Array[a] < Array[b]; }
void Read() {
scanf("%d", &N);
for (int i = 1; i <= N; i++) scanf("%lf", &Array[i]), id[i] ... | CPP |
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 300010;
int n;
pair<int, int> a[MAXN];
int l[MAXN], r[MAXN];
int main() {
scanf("%d", &n);
int x;
for (int i = 1; i <= n; ++i) {
scanf("%d", &x);
a[i] = make_pair(x, i);
l[i] = i - 1;
r[i] = i + 1;
}
sort(a + 1, a + n + 1);
doubl... | CPP |
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
template <typename T>
T sqr(T x) {
return x * x;
}
template <typename T>
T abs(T x) {
return x < 0 ? -x : x;
}
template <typename T>
T gcd(T a, T b) {
return b ? gcd(b, a % b) : a;
}
const int MAXK = 50;
int main(int argc, char **argv) {
ios_base::sync_with_stdio(fa... | CPP |
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int k = 60;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout << setprecision(20) << fixed;
int n;
cin >> n;
vector<pair<int, int>> b;
for (int i = 0; i < n; i++) {
int val;
cin >> val;
b.push_back({val, i});
}
sort(b.begin(), b.... | CPP |
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const long long INF = 1e18;
const int N = 500010;
int n, b[N], l[N], r[N], id[N];
long double ans;
int Write[20];
int read() {
int d = 0, f = 1;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-') f = -1;
c = getchar();
}
wh... | CPP |
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
pair<int, int> pin;
const int maxn = 300005;
inline void read(int &x) {
x = 0;
int f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-') f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
x = x * 10 + ch - '0';
ch = ge... | CPP |
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 300 * 1000;
const int MAXK = 50;
const int INF = 1000 * 1000 * 1000;
int a[MAXN + 2];
int l[MAXN + 2][MAXK];
int r[MAXN + 2][MAXK];
int cntl[MAXN + 2], cntr[MAXN + 2];
set<pair<int, int> > is;
long long two[MAXK + 10];
int main() {
ios_base::sync_with_std... | CPP |
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
int n, a[300010], ord[300010], b[300010];
const int st = 55;
vector<int> lb[300010], rb[300010];
set<int> A;
void read(int &x) {
char ch = getchar();
int mark = 1;
for (; ch != '-' && (ch < '0' || ch > '9'); ch = getchar())
;
if (ch == '-') mark = -1, ch = getch... | CPP |
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
long long rdtsc() {
long long tmp;
asm("rdtsc" : "=A"(tmp));
return tmp;
}
inline int myrand() { return abs((rand() << 15) ^ rand()); }
inline int rnd(int x) { return myrand() % x; }
const int maxn = (int)3e5;
int a[maxn];
pair<int, int> ps[maxn];
double res[maxn];
bo... | CPP |
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int MAX = 400000;
const int NUM = 40;
int n;
int a[MAX], b[MAX], pre[MAX], suf[MAX];
long double Pow[NUM];
int cmp(int l, int r) { return a[l] < a[r]; }
int main() {
int i;
scanf("%d", &n);
for ((i) = (1); (i) <= (n); ++(i)) {
scanf("%d", &a[i]);
b[i] = ... | CPP |
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
inline long long getint() {
long long _x = 0, _tmp = 1;
char _tc = getchar();
while ((_tc < '0' || _tc > '9') && _tc != '-') _tc = getchar();
if (_tc == '-') _tc = getchar(), _tmp = -1;
while (_tc >= '0' && _tc <= '9') _x *= 10, _x += (_tc - '0'), _tc = getchar();... | CPP |
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
int n, a[300000 + 1], seq[300000 + 1], l[300000 + 1], r[300000 + 1], al[60 + 1],
ar[60 + 1];
double d[60 + 1];
inline bool cmp(int x, int y) { return a[x] < a[y]; }
int main(int argc, char *argv[]) {
scanf("%d", &n);
for (int i = 1; i <= n; ++i) scanf("%d", a + i);
... | CPP |
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
#pragma comment(linker, "/STACK:60777216")
using namespace std;
int n;
int b[333333];
vector<pair<int, int> > t;
int rv[333333];
struct Node {
Node *lf;
Node *rg;
int l, r;
int mx;
Node() {
lf = rg = 0;
mx = 0;
}
};
Node *root;
Node *buildTree(int from, int to) {
Node *res... | CPP |
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int N = 1001000;
const int lim = 50;
int a[N], kk[N], nxt[N], pre[N];
long double ans;
int n;
long double p[lim + 10];
bool cmp(int x, int y) { return a[x] < a[y]; }
void work(int id) {
long double ret1 = 0., ret2 = 0.;
int i, x;
for (i = 0, x = id; i <= lim && ... | CPP |
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
int key[300005], pos[300005], pre[300005], nxt[300005], n;
const int maxj = 60;
bool cmp(int x, int y) { return key[x] < key[y]; }
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%d", &key[i]);
pos[i] = i;
pre[i] = i - 1;
nxt[i] = i +... | CPP |
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
struct node {
int w, p;
node() {}
node(int w, int p) : w(w), p(p) {}
} p[N], now;
int n, x, ls, nx, ny, rs, y;
bool tag;
double ans, s1, s2;
int a[N], nxt[N], pre[N], p1[N], p2[N];
bool cmp(node a, node b) { return a.w < b.w; }
void del(int k) {... | CPP |
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
inline void readi(int &x);
const int maxn = 300005;
int n, b[maxn], id[maxn], rk[maxn];
double fl[maxn], fr[maxn];
bool cmpb(const int &i, const int &j) { return b[i] < b[j]; }
struct node {
double div, dta;
node *lc, *rc;
inline void downdate() {
if (div != 1)
... | CPP |
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int N = 300010, T = 60;
int i, j, k, l, m, n, o, p, c[N], pre[N], nex[N], L[200], R[200], tr, tl;
set<int> F;
set<int>::iterator pos;
double a[N], sum, tk[N], mi[N], ans;
inline bool cmp(int i, int j) { return a[i] > a[j]; }
void Init() {
scanf("%d", &n);
for (i =... | CPP |
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int N = 300005;
int n;
struct Node {
int pos, v;
} a[N];
int pre[N], nxt[N];
int main() {
ios::sync_with_stdio(false);
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i].v, a[i].pos = i;
sort(a + 1, a + n + 1, [](Node a, Node b) { return a.v < b.v; });
for... | CPP |
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int N = 300005;
int n, l[N], r[N], p[N], a[N];
double ans, L, R, z;
bool cmp(const int i, const int j) { return a[i] < a[j]; }
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; ++i)
scanf("%d", a + i), p[i] = i, l[i] = i - 1, r[i] = i + 1;
sort(p + 1, p ... | CPP |
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
struct node {
int x, y;
} a[300005];
int l[300005], r[300005], n, i, L, R, j;
double p, q, x, ans;
int cmp(node i, node j) { return i.x < j.x; }
int main() {
scanf("%d", &n);
for (i = 1; i <= n; i++) {
scanf("%d", &a[i].x);
a[i].y = i;
}
for (i = 1; i <= n... | CPP |
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,abm,mmx,tune=native")
using namespace std;
long long gcd(long long i, long long j) {
if (j == 0)
return i;
else
return gcd(j, i % j);
}
template <typename T>
inline T getint() ... | CPP |
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
template <class T>
void debug(T a, T b) {
;
}
template <class T>
void chmin(T& a, const T& b) {
if (a > b) a = b;
}
template <class T>
void chmax(T& a, const T& b) {
if (a < b) a = b;
}
namespace std {
template <class S, class T>
ostream& operator<<(ostream& out, cons... | CPP |
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int k = 30;
int a[300000];
bool cmp(int x, int y) { return (a[x] == a[y]) ? (x < y) : (a[x] > a[y]); }
int main() {
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++) scanf("%d", &a[i]);
static int seq[300000];
for (int i = 0; i < n; i++) seq[i] = i;
sort... | CPP |
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")
#pragma GCC target("avx2")
using namespace std;
template <typename T1, typename T2>
inline void mine(T1 &x, T2 y) {
if (x > y) x = y;
}
template <typename T1, typename T2>
inline void maxe(T1 &x, T... | CPP |
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int N = 300100;
struct dui {
int id, vl;
} a[N];
int ne[N], pre[N], n, st[100], s[100], top1, top2;
bool cmp(dui x, dui y) { return x.vl < y.vl; }
int main() {
int i, j, k, x;
long double ans, res, tmp1, tmp2;
scanf("%d", &n);
for (i = 1; i <= n; i++) {
... | CPP |
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int L = 1001000;
int l[L], r[L], p[L];
double a[L];
int n;
double ans, st, fi, z;
bool cmp(int i, int j) { return a[i] < a[j]; }
void init(void) {
cin >> n;
int i;
for (i = 1; i <= n; i++) {
scanf("%lf", &a[i]);
p[i] = i;
l[i] = i - 1;
r[i] = i +... | CPP |
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
int n, A[300010], L[300010], R[300010];
double sum;
int q[300010];
int cmp(int a, int b) { return A[a] < A[b]; }
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; ++i)
scanf("%d", &A[i]), q[i] = i, L[i] = i - 1, R[i] = i + 1;
sort(q + 1, q + n + 1, cmp);
for... | CPP |
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int N = 1000010, lim = 22;
char buf[1 << 23], *p1 = buf, *p2 = buf;
int l[N], r[N], nxt[N], st[N], tp;
int h[N], n, id[N], rk[N];
double er[31], ans;
int a[31], b[31];
int read() {
int res = 0, fl = 0;
char a =
(p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1... | CPP |
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
double ans;
long long N;
vector<pair<double, int> > ar;
set<int> myset;
set<int>::iterator it;
bool comp(const pair<double, int> &a, const pair<double, int> &b) {
return a.first > b.first;
}
double g(int x) {
double l = 0, r = 0, div;
int last;
myset.insert(ar[x].se... | CPP |
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
const int MAXN = 300010;
int n, a[MAXN];
std::vector<std::pair<int, int> > v;
std::set<int> s;
double solve(int x) {
double two, c1, c2;
int cnt, prev, y;
s.insert(x);
std::set<int>::iterator it = s.find(x);
two = 1.0;
cnt = 0;
prev = x;
c1 = 0.0;
while (cnt < 50) {
y = *(... | CPP |
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 3e5 + 10;
int n, arr[MAXN], all[MAXN];
double answer;
set<int> s;
bool cmp(int l, int r) {
if (arr[l] != arr[r]) return arr[l] > arr[r];
return l > r;
}
int main() {
ios::sync_with_stdio(0);
cin >> n;
for (int i = 0; i < n; i++) cin >> arr[i];
f... | CPP |
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
inline int read() {
int x = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-') f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
x = x * 10 + ch - '0';
ch = getchar();
}
return x * f;
}
double ans = 0;
int n, ... | CPP |
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
inline int read() {
int res = 0;
int neg;
while (true) {
char ch = getchar();
if (ch >= '0' && ch <= '9' || ch == '-') {
if (ch == '-')
neg = -1;
else
neg = 1, res = ch - '0';
break;
}
}
while (true) {
char ch = ge... | CPP |
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int N = 333333;
int a[N];
int pos[N];
set<int> s;
int n;
bool cmp(const int pos1, const int pos2) {
if (a[pos1] != a[pos2]) return a[pos1] > a[pos2];
return pos1 < pos2;
}
double calc(int pos) {
set<int>::iterator sit;
int prev;
double c1 = 0, c2 = 0, two;
... | CPP |
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
int n;
int t[300300];
void add(int k) {
while (k < 300300) t[k]++, k += (k & -k);
}
int sum(int k, int s = 0) {
while (k) s += t[k], k -= (k & -k);
return s;
}
int b[300300], id[300300];
bool cmp(int i, int j) { return b[i] > b[j]; }
int pre[300300], nxt[300300];
int ... | CPP |
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
int n, i, j, p, b[310000], tx[310000];
double ans, pia[310000], sum[410000], mu[410000];
struct aa {
double mul, sum;
aa operator+(aa b) {
aa c;
c.mul = mul * b.mul;
c.sum = sum + mul * b.sum;
return c;
}
} s[1210000];
bool cmp(int x, int y) {
if (b[... | CPP |
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int MAXBUF = 1 << 23;
char B[MAXBUF], *Si = B, *Ti = B;
inline char getc() {
if (Si == Ti) Ti = (Si = B) + fread(B, 1, MAXBUF, stdin);
if (Si == Ti)
return 0;
else
return *Si++;
}
template <class T>
inline void read(T &a) {
static char c;
static int ... | CPP |
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
bool debug = 1;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
long long ln, lk, lm;
pair<int, int> a[300105];
int pre[300105], nxt[300105];
double ans;
int main() {
scanf("%d", &n);
for (int(i) = 1; (i) <= (int)(n); (i)++) {
scanf("%d", &a[i].first)... | CPP |
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int N = 3000 * 100 + 10, LOG = 65;
pair<int, int> a[N];
set<int> s;
int le[LOG], ri[LOG];
long double p[LOG];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
for (int i = 0; i < n; i++) cin >> a[i].first, a[i].second = i;
sort(a, a ... | CPP |
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int N = 300005;
const int mo = 1000000007;
inline int IN() {
char ch;
(ch = getchar());
int f = 0, x = 0;
for (; ((ch) == '\n' || (ch) == '\r' || (ch) == '\t' || (ch) == ' ');
(ch = getchar()))
;
if (ch == '-') f = 1, (ch = getchar());
for (; !(... | CPP |
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int N = int(3e5) + 50, K = 60, inf = ~0u >> 2;
int B[N], n, cLeft[N][K], cRight[N][K], buf[N];
set<int> S;
int main() {
cin >> n;
for (int i = 1; i <= n; ++i) cin >> B[i];
B[0] = B[n + 1] = inf;
for (int i = 0; i <= n + 1; ++i) buf[i] = i;
sort(buf, buf + n ... | CPP |
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MAXN = 300010;
const int TINY = 1e-13;
int N;
double b[MAXN];
pair<double, int> first[MAXN];
const int MAXS = 24;
int Ls, Rs;
int L[MAXS], R[MAXS];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout << setprecision... | CPP |
380_E. Sereja and Dividing | Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:
1. choose an index of the sequence element i (1 β€ i β€ |a|);
2. consecutively perform assignments: <image>.
Let's use function g(a, x) to represent the large... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 5;
const long long linf = 1e18 + 5;
const int N = 3e5 + 5;
int n;
pair<int, int> a[N];
set<int> s;
int main() {
ios ::sync_with_stdio(0);
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i].first;
a[i].second = i;
}
sort(a + 1, a + n... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
template <class T>
T abs(T x) {
return x > 0 ? x : -x;
}
long long n;
int m;
int c[10];
int i[10];
int d[18];
int main() {
scanf("%I64d %d", &n, &m);
for (int j = 0; j < 10; ++j) c[j] = 0;
for (; n > 0; n /= 10) ++c[n % 10];
long long f[c[0] + 1][c[1] + 1][c[2] + ... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | import java.util.*;
import java.io.*;
public class Main {
FastScanner in;
PrintWriter out;
final int DIGITS = 10;
int[] cnt = new int[DIGITS];
class Masks implements Comparable<Masks>{
int x, y;
Masks(int x, int y) {
this.x = x;
this.y = y;
}
... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main{
public static void main(String[] args) {
solve();
}
static int mod, state[] = new int[11];
static Long dp[][];
private static void solve() {
char num[] = IN.next(... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int M, cnt[10], base[10], mult[11];
long long dp[27000][100];
int main() {
long long n;
cin >> n >> M;
while (n) {
cnt[n % 10]++;
n /= 10;
}
mult[0] = 1;
for (int i = 0; i < 10; i++) {
base[i] = cnt[i] + 1;
mult[i + 1] = mult[i] * base[i];
}
... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
template <typename Tp>
inline void outarr(Tp _begin, Tp _end, const char* _delim = " ") {
for (Tp current = _begin; current != _end; ++current) {
std::cout << *current << _delim;
}
std::cout << '\n';
}
using ll = long long;
using pii = std::pair<int, int>;
constex... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
template <typename T, size_t N>
int SIZE(const T (&t)[N]) {
return N;
}
template <typename T>
int SIZE(const T &t) {
return t.size();
}
string to_string(const strin... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
string n;
int nsz;
int m;
long long dp[1 << 18][100];
long long rec(int a, int b, int mask) {
if (b == nsz) return (long long)(a == 0);
if (dp[mask][a] >= 0) return dp[mask][a];
dp[mask][a] = 0LL;
for (int i = 0; i < nsz; i++) {
if (((mask >> i) & 1) ||
... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
struct point {
int a;
unsigned long long b;
bool operator<(const point A) const {
if (a != A.a) return a < A.a;
return b < A.b;
}
};
int l;
unsigned long long d[30], r[30], two[30], n, m;
int wh[(1 << 18) + 10];
queue<point> Q;
unsigned long long dp[110][(1 ... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
long long v;
int n, m;
long long dp[1 << 18][100];
int num[100], cnt[100];
int N;
void solve() {
N = 1 << n;
dp[0][0] = 1;
for (int i = 0; i < n; i++) {
if (num[i] > 0) dp[1 << i][num[i] % m] += 1;
}
for (int i = 1; i < N; i++) {
for (int j = 0; j < m; j++... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 1 << 18;
const int maxm = 1e6 + 10;
const int INF = 0x3f3f3f3f;
long long casn, n, m, k;
long long dp[maxn][100];
int num[123];
int tms[123];
int len;
long long pw[123];
int main() {
int a, b, c;
cin >> n >> m;
long long x = n;
while (x) {
num[l... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;
/**
* @author khokharnikunj8
*/
public class Main {
public static void main(... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | import java.util.*;
public class d {
static int m;
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
long x = input.nextLong();
int n = (x+"").length();
m = input.nextInt();
int[]counts = new int[10];
for(int i = 0; i<n; i++)
{
counts[(int)(x%10)]++... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
public class Abood2C {
static int N;
static long memo[][];
static int MOD;
static String s;
static long so... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
long long n, fact[19], dp[1 << 18][100];
int m, td, dig[18], f[10];
int main() {
scanf("%lld %d", &n, &m);
while (n) {
dig[td++] = n % 10;
f[n % 10]++;
n /= 10;
}
for (int i = 0; i < td; i++) {
if (dig[i] == 0) continue;
dp[(1 << i)][dig[i] % m]+... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
const long long inf = 2e18;
using namespace std;
template <class T, class T2>
void smin(T& a, T2 val) {
if (a > val) a = val;
}
template <class T, class T2>
void smax(T& a, T2 val) {
if (a < val) a = val;
}
const int N = 5 * (int)1e5 + 10;
long long n, mod;
long long dp[1LL << 18][100];
vec... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
long long w[1 << 18][128], d = 1;
char n[88];
int main() {
int l, m, t, c[16] = {0};
cin >> n >> m;
l = strlen(n), t = 1 << l;
w[0][0] = 1;
for (int i = 0; i < l; ++i) d *= ++c[n[i] -= '0'];
for (int i = 0; i < t; ++i)
for (int j = 0; j < l; ++j)
if (!... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;
/**
* @author khokharnikunj8
*/
public class Main {
public static void main(String[] args) {
... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | import java.util.*;
import java.io.*;
public class Main{
BufferedReader in;
StringTokenizer str = null;
private String next() throws Exception{
if (str == null || !str.hasMoreElements())
str = new StringTokenizer(in.readLine());
return str.nextToken();
}
private int ne... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int N = 2005;
long long f[1 << 18][101];
string s;
int n, mod, Pow[20];
long long lui(int st, int remain) {
if (st == 0) return remain == 0;
if (f[st][remain] != -1) return f[st][remain];
long long res = 0, cnt = 0;
for (int i = 0; i < n; i++) cnt += (st >> i)... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const long long MAXN = (1 << 18);
const long long MAXM = 100;
string n;
long long lgn, m;
void read() { cin >> n >> m; }
long long dp[MAXN][MAXM];
long long rec(long long mask, long long ost) {
long long i = __builtin_popcount(mask);
if (i == lgn) return (ost == 0);
l... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
long long int dp[300000][105];
int used[15];
int a[20];
int n, m;
string s;
int main() {
cin >> s >> m;
n = s.size();
for (int i = 0; i < n; i++) {
a[i] = s[i] - '0';
}
dp[0][0] = 1;
for (int mask = 0; mask < (1 << n); mask++) {
for (int mod = 0; mod < m... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
long long n;
int m, a[20], tot;
long long f[(1 << 18) + 10][110];
long long dfs(int x, int S, int mod, int zero) {
if (!x) return mod == 0;
if (f[S][mod] != -1) return f[S][mod];
long long res = 0;
bool vis[10];
memset(vis, 0, sizeof(vis));
for (int i = 0; i < t... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
string s;
long long m, dig[29] = {}, l, memo[(1 << 18) + 2][103];
long long dp(int mask, int mod, int bno) {
if (memo[mask][mod] != -1) return memo[mask][mod];
if (bno == l) {
return memo[mask][mod] = 1;
}
memo[mask][mod] = 0;
for (int i = 0; i < l; i++) {
... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | import java.io.*;
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
public class cf401d_2 {
public static void main(String[] args) throws IOException {
r();
char[] nch = input.nextToken().toCharArray();
int m = ni(), len = nch.length, n[] = new int[len]... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | import java.util.*;
import java.io.*;
public class TaskD {
private FastScanner in;
private PrintWriter out;
private int MAX_SIZE;
public void solve() throws IOException {
long n = in.nextLong(), m = in.nextLong();
char[] data = Long.toString(n).toCharArray();
int[] digits = new... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*/
public class Main {
public static void main(String[] args) {
Input... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.PriorityQueue... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | import java.awt.*;
import java.io.*;
import java.util.*;
public class Abc {
static long dp[][];
static int dig[];
static int n;
static int r;
static int m;
public static void main(String[] args) {
FastReader sc = new FastReader();
String s=sc.next();m=sc.nextInt();
n=s.l... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
inline long long read() {
long long x = 0, neg = 1;
char c = getchar();
while (!isdigit(c)) {
if (c == '-') neg = -1;
c = getchar();
}
while (isdigit(c)) x = x * 10 + c - '0', c = getchar();
return x * neg;
}
long long n = read(), m = read();
long long a... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | import java.io.*;
import java.util.*;
public class D
{
static StringBuilder st = new StringBuilder();
static long [][] memo ;
static char [] s ;
static int mult(int a , int b , int MOD) {return (int)((1l * a * b) % MOD) ; }
static int add(int a , int b , int MOD) {return (a+b) % MOD;}
static int ... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | //package codeforces;
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class D implements Closeable {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
Print... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 |
import java.io.*;
import java.util.*;
public class D {
FastScanner in = new FastScanner(System.in);
PrintWriter out = new PrintWriter(System.out);
int count(long x) {
int res = 0;
while (x > 0) {
if (x % 2 != 0)
res++;
x /= 2;
}
return res;
}
public void run() {
String s = in.next();
int... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
struct st {
int tmp;
int cnt[10];
bool operator<(const st &i) const { return tmp < i.tmp; }
};
map<string, long long> d[20][101];
map<string, long long>::iterator it;
long long n, t;
int m, cnt[10], p;
long long re;
string tmp = "0000000000";
int main(void) {
scanf(... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
long long n;
int f[20], num, m, maxn, g[10];
long long dp[1 << 18][100];
bool flag;
int main() {
memset(f, 0, sizeof(f));
memset(dp, 0, sizeof(dp));
cin >> n >> m;
num = 0;
if (n % m == 0)
flag = true;
else
flag = false;
while (n) {
f[num++] = n % ... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Scanner;
/**
* Built using CHelper plug-in Actual solution is at the top
*/
public class Main {
public static void main(String[] args) {
TaskD t = new TaskD();
t.solve();
}
}
class TaskD {
long ways[][];
char no... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | import java.util.Scanner;
import java.io.OutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
* @author Himalay(himalayjoriwal@gmail.com)
*/
public class Main {
public static void main(String[] args) ... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 |
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
public class Main {
public static void main(String[] args) {
InputReader in = new InputReader(System.in);
PrintWri... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | import java.lang.*;
import java.io.*;
import java.util.*;
public class Main {
public static void main(String args[]) throws IOException { new Main().bw.close(); }
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | import java.util.*;
import java.io.*;
public class RomanandNumbers {
/************************ SOLUTION STARTS HERE ************************/
static int mod;
static int digits[];
static long memo[][];
static long rec(int mask , int sum) {
if(Integer.bitCount(mask) ==... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int m, num[10], a[10], pov[10], all, dig, dd;
long long n, f[1 << 18][110], ten[20];
void teg(int ip) {
dig = 0;
for (int i = 9; i >= 0; i--) a[i] = ip % num[i], ip /= num[i], dig += a[i];
}
int main() {
scanf("%lld%d", &n, &m);
while (n) num[n % 10]++, n /= 10, dd+... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 |
import java.io.*;
import java.util.*;
public class D {
FastScanner in = new FastScanner(System.in);
PrintWriter out = new PrintWriter(System.out);
int count(long x) {
int res = 0;
while (x > 0) {
if (x % 2 != 0)
res++;
x /= 2;
}
return res;
}
public void run() {
String s = in.next();
int... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
long long n;
int m, len;
long long dp[1 << 18][100];
int cnt[10];
int A[20];
int main() {
cin >> n >> m;
memset(cnt, 0, sizeof(cnt));
;
memset(dp, 0, sizeof(dp));
;
memset(A, 0, sizeof(A));
;
long long N = n;
len = 0;
while (N) {
A[len] = N % 10;
... | CPP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.