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 |
|---|---|---|---|---|---|
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
char str[100111];
int n;
bool overflow[100111];
int arr[100111];
bool Try(bool of) {
int i;
int val;
int rem, sum;
memset(overflow, false, sizeof(overflow));
overflow[n + 1] = false;
if (!of) {
overflow[1] = false;
overflow[n] = false;
}
if (of) {
... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int Nmax = 100000 + 10;
int n;
int nr[Nmax];
char s[Nmax], ans[Nmax];
bool ok(int L, int R) {
int i, sum;
if (L > R) return 0;
for (i = 1; i <= n; ++i) nr[i] = s[i] - '0';
if (L == 1 && nr[R] == 0) return 0;
if (L == 2 && nr[1] != 1) return 0;
for (nr[L] +... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
template <typename T>
T in() {
char ch;
T n = 0;
bool ng = false;
while (1) {
ch = getchar();
if (ch == '-') {
ng = true;
ch = getchar();
break;
}
if (ch >= '0' && ch <= '9') break;
}
while (1) {
n = n * 10 + (ch - '0');
... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
bool viz[100100];
int g[100100], wh, n;
vector<int> G[100100];
string s;
char a[100100], b[100100];
void dfs(int x) {
viz[x] = true;
g[x] = wh;
for (int i = 0; i < G[x].size(); ++i) {
if (!viz[G[x][i]]) dfs(G[x][i]);
}
}
void explore() {
wh = 0;
for (int i =... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int limite = 200000;
int n = 0;
int v[limite];
int memhaysol[limite][2][2];
int esuma[limite][2][2];
int ele[limite][2][2];
int eri[limite][2][2];
int sol[limite];
int calculado[limite][2][2];
int haysol(int i, int cle, int cri) {
int &mem = memhaysol[i][cle][cri];
... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
#pragma comment(linker, "/STACK:268435456")
using namespace std;
template <typename T>
inline T abs(T a) {
return ((a < 0) ? -a : a);
}
template <typename T>
inline T sqr(T a) {
return a * a;
}
template <class T>
T gcd(T a, T b) {
return a ? gcd(b % a, a) : b;
}
template <class T>
T lcm(T... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
string solve(string& n, int len) {
if (len == 0) return "";
for (int i = 0; i < n.size() - 1 - i; ++i) swap(n[i], n[n.size() - 1 - i]);
vector<int> s(len, 0);
char ret[len + 1];
for (int i = 0; i < (len + 1) / 2; ++i) {
if (n[i] < '0') {
n[i + 1]--;
... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int NMAX = 1e5 + 1e2;
int n;
int le, ri;
char s[100007];
int main() {
ios::sync_with_stdio(false);
cin >> s;
for (ri = 0;; ri++) {
if (!s[ri])
break;
else
s[ri] -= '0';
}
n = ri--;
if (s[le] - s[ri]) {
s[le + 1] += 10;
--s[le] ?... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
string S;
vector<vector<vector<int> > > cc;
int dp(int idx, int d, int s) {
int &ret = cc[idx][d][s];
if (ret != -1) return ret;
if (idx == S.size() / 2) {
if (S.size() % 2) {
int x = S[idx] - '0';
if ((10 * d + x - s) < 0 || (x - s) % 2)
retur... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
string s;
int n, a[100005], b[100005];
bool f;
void cty(int o) {
int q = 0;
for (int i = 1; i <= n; i++) q = q * 10 + a[i];
int c[10];
for (int i = 1; i <= o; i++) c[i] = 9;
while (c[1]) {
int r = 0, r2 = 0;
for (int i = 1; i <= o; i++) r = r * 10 + c[i];
... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | def digits(n):
rd = []
while n:
n, d = divmod(n, 10)
rd.append(d)
return list(reversed(rd))
def _ifs(dn, i, j, ci, cj, al, ar):
while i < j:
di = dn[i] + 10*ci
dj = dn[j] - cj
for (ci, cj) in ((0, 0), (0, 1), (1, 0), (1, 1)):
d = di - ci
... | PYTHON3 |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, Ans[N], l, r, flag, B[N];
char str[N];
void write() {
int flag = 0;
for (int i = 1; i <= n; i++)
if (Ans[i] > 9 || Ans[i] < 0) return;
for (int i = 1; i <= n; i++) {
if (Ans[i] == 0 && flag == 0) continue;
printf("%d", Ans[i]);... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using uint8 = unsigned char;
using uint16 = unsigned short int;
using uint32 = unsigned int;
using uint64 = unsigned long long;
using int8 = signed ch... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int n = 100002;
char h[n], h1[n];
int a[n];
bool check(int e, int r, int v1, int c1) {
int c, v, c2, v2;
while (e < r) {
for (c = 0; c < 10; c++)
for (v = 0; v < 10; v++)
if (c + v == v1 + h[r]) {
if ((c == 0) && (e == 0)) continue;
... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
template <class T1, class T2>
bool chmin(T1 &a, T2 b) {
return b < a && (a = b, true);
}
template <class T1, class T2>
bool chmax(T1 &a, T2 b) {
return a < b && (a = b, true);
}
int ans[101010];
bool vis[101010][2][2];
void dfs(string &s, int l, int r, int carryLeft, in... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
char str[100010];
int ans[100010];
int out[100010];
int n, a[100010];
bool check(int x, int y, int &need, int &jin, int &sum) {
for (int i = 0; i <= 18; i++) {
if (i / 10 == need && i % 10 == x && (i + jin) % 10 == y) {
jin = (i + jin) / 10, need = 0, sum = i;
... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int arr[100000];
int arr2[100000];
int input[100000];
int f(int x) {
if (x < 10)
return 0;
else
return (x - 9);
}
int main() {
string n;
cin >> n;
int N = n.length();
for (int i = 0; i < N; i++) {
input[i] = n[N - 1 - i] - '0';
}
int ans[N];
bo... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
char s[100007];
int l, r, n;
int main() {
scanf("%s", s);
for (r = 0;; ++r)
if (!s[r])
break;
else
s[r] -= '0';
n = r--;
if (s[l] - s[r]) s[l + 1] += 10, --s[l] ? 0 : ++l;
for (; l <= r; ++l, --r) {
if (s[l] - s[r]) {
if (s[l] - s[r] >= 10 && s[r] < 10) -... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
char s[N];
int b[N], r[N], l;
bool go() {
int i, j;
for (i = 1, j = l; i <= j;) {
if (b[i] == b[j]) {
++i, --j;
} else if (b[i] == b[j] + 10) {
b[j - 1]--;
b[j] += 10;
} else if (b[i] == b[j] + 1 || (b[i] == b[j] + 11... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
char str[maxn];
int n, x[maxn], a[maxn], b[maxn], c[maxn];
void failed() {
puts("0");
exit(0);
}
int main() {
scanf("%s", str);
n = strlen(str);
for (int i = 0; i < n; i++) x[i] = str[i] - '0';
for (int bgn = 0; bgn <= 1 and bgn < n; bg... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
#pragma comment(linker, "/STACK:10000000000")
#pragma GCC optimize("O3")
using namespace std;
const int MOD = 1000000007;
const int INF = 1000000007LL;
const long long INF2 = 1000000007LL * 1000000007LL;
const long double EPS = 1e-9;
const int SIZE = 200010;
mt19937 rng(time(0));
uniform_int_di... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int v[2][100010], ans[100010];
int n = 0;
bool debug = 0;
bool solve(int k, int l) {
if (debug) cout << "solve" << k << '\n';
int r = n - 1;
while (l <= r) {
if (debug)
cout << l << " " << r << " " << v[k][l] << " " << v[k][r] << '\n';
if (l == r) {
... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
long double memo[100010][3][2];
int n;
string s;
char A[100012];
char B[100012];
long double dp(int pos, int cl, int cr) {
if (abs(memo[pos][cl][cr] + 1) > 1e-6) return memo[pos][cl][cr];
int posl = n + 1 - pos;
if (posl == pos) {
long double ans = 0;
for (int... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const double PI = acos(-1);
const int maxn = 101000;
string S;
int ans[maxn];
bool spe;
int le;
void solve(string S, bool tp) {
bool lc, rc;
lc = tp;
rc = false;
bool temp = false;
for (int i = 0; i < S.length(); i++) {
int j = S... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int n, a[1000000], ans[1000000];
char s[1000000];
int main() {
scanf("%s", s);
int n = strlen(s);
for (int i = 1; i <= n; i++) a[i] = s[i - 1] - 48;
if (n == 1 && a[1] % 2) {
puts("0");
return 0;
}
int i = 1, j = n;
if (a[1] != a[n]) {
--a[1];
... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
double PI = 4 * atan(1);
string x;
bool p = false;
int ori, final[100000];
vector<int> n, n1, ans;
pair<int, int> v[19];
void subtract(int x) {
n[0] -= x;
n[n.size() - 1] -= x;
int ind = n.size() - 1;
while (ind > 0 && n[ind] < 0) {
n... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int mxn = 100006;
int n;
char s[mxn];
int a[mxn];
int b[mxn];
int b_[mxn];
int ans[mxn];
bool cal(int l_, int r_) {
for (int i = 0; i < n; ++i) a[i] = s[n - 1 - i] - '0';
fill(b, b + n, 0);
auto carry = [](int x) {
if (a[x] < 0) {
a[x] += 10;
--a... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
char n[N], a[N];
bool solve(int d, char* n, char* a) {
int di = n[0], dj = n[d - 1], i = 0, j = d - 1;
while (i < j) {
int carry = 0;
if (di - 10 == dj) dj += 10, carry = 1;
if (di - 11 == dj) dj += 10, carry = 1;
carry |= dj > 9;... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5;
char buff[MAXN + 5];
int arr[MAXN + 5], temp[MAXN + 5], ans[MAXN + 5];
bool ok(int arr[], int n, int c) {
int carry_from_left = c;
int carry_to_right = 0;
int i, j;
for (i = 0; i < n / 2; i++) {
j = n - 1 - i;
if (carry_from_left) arr[i... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int main() {
std::string n;
std::cin >> n;
int a[100000], b, ans[100000];
b = n.size();
for (int i = 0; i < b; i++) {
a[i] = (int)n[i] - 48;
}
bool p[2];
p[0] = true;
p[1] = true;
int w, r, prm, prp;
w = 0;
r = b - 1;
prm = 0;
prp = 0;
if (... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
char num[1000050];
int n[1000050];
char left[1000050];
int len;
bool Cout[1000050];
int ans[1000050];
bool check(int start) {
for (int i = start, j = len - 1; j >= i; j--, i++) {
int t1 = n[i] + 10 * Cout[i], t2 = n[j] + 10 * Cout[j];
if (t1 == t2 && t1 < 19) {
... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
char s[100010];
int a[100010];
int main() {
scanf("%s", s);
int len = strlen(s);
for (register int i = 0; i < len; ++i) a[i] = s[i] - '0';
int l = 0, r = len - 1;
if (a[l] != a[r]) {
a[l]--;
a[l + 1] += 10;
if (!a[l]) ++l;
}
while (l <= r) {
if... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
inline int read() {
int first = 0, f = 1;
char ch = getchar();
for (; ch < '0' || ch > '9';) {
if (ch == '-') f = -1;
ch = getchar();
}
for (; ch >= '0' && ch <= '9';) {
first = first * 10 + ch - '0';
ch = getchar();
}
return first * f;
}
char ... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
struct debugger {
template <typename T>
debugger& operator,(const T& v) {
cerr << v << " ";
return *this;
}
} dbg;
struct PT {
int i, j, k;
PT(int x, int y, int z) : i(x), j(y), k(z) {}
PT() {}
};
bool dp[50010][2][2];
char soll[50010][2][2], solr[50010]... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | def main():
a = map(int, raw_input())
n = len(a)
left, right = 0, n - 1
if a[left] != a[right]:
a[left] -= 1
a[left + 1] += 10
if 0 == a[left]: left += 1
while left <= right:
if a[left] != a[right]:
if a[left] - a[right] >= 10 and a[right] < 10:
a[right] += 10
a[right - 1] -= 1
if 1 == a[left... | PYTHON |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 5;
const long long mod = 1e9 + 7;
const long long inf = 1e18;
const long long X = 316;
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};
string s;
int f[N], a[N];
bool solve(int i, int j, int l, int r) {
int newl, newr;
if (i > j) return l ==... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
InputReader in = new InputReader(inputStream);
PrintWriter out = new PrintWriter(outputStream);
solve(in, out);
out.close();
}
... | JAVA |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 100100;
int n;
string s;
int a[maxn];
int ans[maxn], done;
void check(int l, int dl, int r, int dr) {
for (;; l++, r--) {
if (l == r) {
ans[l] = (dl * 10 + a[l]) / 2;
done = !((a[l] - dr) & 1);
return;
} else if (l == r + 1) {
... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
std::string s;
int l;
std::string work(int opt, std::string s) {
int tl = l, last_carry = 0, need_carry = opt;
if (opt == 1) tl--;
std::string ret(tl, '0');
for (int i = 0; i <= tl - i - 1; i++) {
bool conc = false;
if (!last_carry && need_carry && s[i] == '9' && s[tl - i - 1] =... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, Ans[N], l, r, flag, B[N];
char str[N];
void write() {
int flag = 0;
for (int i = 1; i <= n; i++)
if (Ans[i] > 9 || Ans[i] < 0) return;
for (int i = 1; i <= n; i++) {
if (Ans[i] == 0 && flag == 0) continue;
printf("%d", Ans[i]);... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
void read(vector<int> &d) {
d.clear();
for (char c(getchar()); isdigit(c); c = getchar()) d.push_back(c - '0');
reverse(d.begin(), d.end());
}
void write(vector<int> d) {
for (int i(d.size()); i; --i) printf("%d", d[i - 1]);
}
void write(int a) { printf("%i", a); }
... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int N = 100005;
char num[N];
int n;
int c[N];
int ans[N];
bool judge() {
if (n == 0) return false;
int i = 0;
for (; i < n / 2; i++) {
int j = n - i - 1;
if (c[i] == c[j] + 1) {
c[i]--;
c[i + 1] += 10;
} else if (c[i] == c[j] + 10) {
... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int a[111111], b[111111];
char s[111111];
int dfs(int i, int j, int l, int r) {
if (i > j) return l == r;
b[i] += l * 10;
b[j] -= r;
if (b[i] - b[j] > 9)
b[j] += 10, r = 1;
else
r = 0;
if (b[i] > b[j])
b[i]--, l = 1;
else
l = 0;
if (b[i] > 18... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int num[100100];
int num1[100100];
int n;
bool valido(int x) {
if (x >= 0 && x <= 18) return 1;
return 0;
}
bool remove(int j) {
while (num[j] < 0) {
num[j + 1]--;
num[j] += 10;
if (num[j] >= 0) j++;
if (j > n + 1) return 0;
}
return 1;
}
int sol[1... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
char s[100005];
int a[100005];
int len;
bool produce(int l, int r, bool &f1, bool &f2) {
if (f1 && f2) {
if (s[l] + 1 == s[r] || s[l] == s[r]) {
switch (s[r]) {
case 0:
a[l] = 9;
a[r] = 0;
break;
case 1:
a[... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
string s;
vector<int> a;
const int maxn = 100100;
int ans[maxn];
int n;
bool check(int l, int r) {
if (a[l] == a[r] - 1 && (r + 1 < n && a[r + 1] > 9)) {
return false;
}
return true;
}
bool solve() {
for (int i = 0; i < (n / 2); i++) {
int l = i;
int r =... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | def solve(N):
a, b = 0, len(N)-1
Head, Tail = [], []
while a+1 < b:
A = N[a]
B = N[b]
if A%2 != B%2:
A -= 1
N[a+1] += 10
if A > B:
B += 10
N[b-1] -= 1
if A != B:
return False
if A == 0 and a == 0:
... | PYTHON3 |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
long long powmod(long long a, long long b, long long MOD) {
long long res = 1;
a %= MOD;
for (; b; b >>= 1) {
if (b & 1) res = res * a % MOD;
a = a * a % MOD;
}
return res;
}
const int N = 1E5 + 5;
char s[N];
int a[N];
char out[N];
bool solve(int n) {
fo... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 |
import java.util.*;
import java.io.*;
public class Solutions
{
public static boolean solve(int[] a, int n)
{
int remainder1, remainder2, carry = 0;
if (n % 2 == 0)
{
for (int i = 0; i < n / 2; i++)
{
remainder1 = a[n - 1 - i] % 10;
... | JAVA |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, digit[N];
char st[N], str[N];
bool over = false;
void deal(int k, int s, int t) {
if (k > (n + 1) / 2) {
printf("%s\n", str + 1);
over = true;
} else {
for (int i = (0); i <= (9); i++)
for (int j = (0); j <= (9); j++) {
... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | import java.io.*;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws IOException {
Reader in = new Reader(new InputStreamReader(System.in));
PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
char[] s = in.next().toCharA... | JAVA |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 100;
char s[maxn];
int a[maxn], b[maxn], sum[maxn], flag[maxn];
int tmpa[maxn], tmpb[maxn], ans[maxn];
int nb[maxn];
int len;
void read() {
scanf("%s", s);
for (int i = 0; s[i]; i++) b[i + 1] = s[i] - '0';
nb[1] = b[1] * 10 + b[2];
for (int... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const int N = 1e5 + 10;
char ch[N];
int f[N], g[N];
int n;
void init() {
scanf("%s", ch + 1);
n = strlen(ch + 1);
for (int i = 1; i <= n; i++) f[i] = ch[i] - '0', g[i] = f[i];
}
bool check(int l) {
for (int i = l, j = n; i < j; i++, j-... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual soluti... | JAVA |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int n, arr[100010], ans[100010];
char aa[100010];
bool run(int *abb) {
int beg = 1, end = n;
while (beg < end) {
if (abb[beg] < 0) return false;
if (abb[end] < 0) {
if (abb[end] == -1) {
abb[end - 1] -= 1;
abb[end] += 10;
} else
... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 7;
char s[maxn];
char ans[maxn];
int sum[maxn];
int n;
int check() {
for (int i = 0; i < n / 2;) {
int l = i, r = n - 1 - i;
if (sum[l] == sum[r])
i++;
else if (sum[l] == sum[r] + 1 || sum[l] == sum[r] + 11) {
sum[l]--;
... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
string data;
int ans[100011];
int ddtt[100001];
int st = 0, K;
bool check() {
for (int i = 0; i < K / 2;) {
int l = i, r = K - i - 1;
if (ddtt[l] == ddtt[r])
i++;
else if (ddtt[l] == ddtt[r] + 1 || ddtt[l] == ddtt[r] + 11) {
ddtt[l]--;
ddtt[i... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5;
char s[maxn];
int a[maxn];
int n, l, r, i, x;
int main() {
scanf("%s", s + 1);
n = strlen(s + 1);
for (i = 1; i <= n; i++) a[i] = s[i] - '0';
l = 1;
r = n;
if (a[l] != a[r]) {
a[l]--;
a[l + 1] += 10;
if (!a[l])
l++;
el... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | // practice with rainboy
import java.io.*;
import java.util.*;
public class CF625D extends PrintWriter {
CF625D() { super(System.out, true); }
Scanner sc = new Scanner(System.in);
public static void main(String[] $) {
CF625D o = new CF625D(); o.main(); o.flush();
}
boolean solve(byte[] cc, byte[] aa, int n) {
... | JAVA |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int maxN = 5e5 + 5;
int n;
char s[maxN];
int res[maxN];
bool Cal(int st, int en, int po, int cr) {
if (st > en) return (po == cr);
int s1 = (s[st] - '0') + 10 * po, s2 = (s[en] - '0') - cr, crr = 0, poo = 0;
if (st == en) s1 = s2 = s[st] - '0' + 10 * po - cr;
... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int main() {
string b;
cin >> b;
if (b == "1") {
cout << "0" << endl;
return 0;
}
int n = (int)((b).size());
string a((int)((b).size()), '-');
bool flag = true;
if (n > 2) {
if (b[0] != '1') flag = false;
for (__typeof(n) i = (1); i != (n); i... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #!/usr/bin/python3
def can(s, n):
if n == 0:
return ""
cs = list(map(int, s))
was_over = [False for i in range(n)]
ans = [0 for i in range(n)]
i, j = 0, n - 1
last = int(n == len(cs) - 1)
while i < j:
need_a = last * 10 + cs[i]
need_b = last * 10 + cs[j]
... | PYTHON3 |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int MAX = 100002;
int main() {
char s[MAX];
scanf("%s", s);
int n = strlen(s), i;
vector<int> number(n), res(n), target(n);
number[0] = 0;
for (i = 0; i < n; i++) {
number[i] = s[i] - '0';
}
int right, left;
right = n - 1;
left = 0;
target = ... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
const int INF = 0x3f3f3f3f;
const int NINF = -INF - 1;
const int mod = 1e9 + 7;
const int N = 1e5 + 5;
using namespace std;
char a[N];
int ans1[N];
int ans2[N];
int sum1[N];
int sum2[N];
int check(int lenth) {
int g1 = 0, g2 = 0;
for (int i = 0; i < lenth; i++) sum2[i] = sum1[i];
for (int... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
char a[100005];
int s[100005], l, r;
void minchange1(int x) {
s[l] = (l == 0) ? 1 : 0;
s[r] = (l == 0) ? x - 1 : x;
}
void minchange2(int x) {
s[l] = x - 9;
s[r] = 9;
}
int main() {
while (cin >> a) {
int len = strlen(a), k = 0, blag = 0;
l = 0, r = len - ... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | import java.io.*;
import java.util.*;
public class D {
FastScanner in;
PrintWriter out;
char[] a;
char[] c;
int n;
HashMap<Long, Boolean> mem = new HashMap<>();
long code(int l, int r, int to, int from) {
return ((l * 1L * n + r) * 2 + to) * 2 + from;
}
boolean ans(long id, boolean x) {
mem.put(id, x)... | JAVA |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int N = 100002;
int n, start, dp[N][2][2], ans[N];
char a[N];
bool solve(int i, int j, int c1, int c2) {
int &ret = dp[i][c1][c2];
if (ret != -1) return ret;
if (i > j) return ret = (!c1 and !c2) or (c1 and c2);
if (i == j) return ret = (a[i] - '0' + c1 * 10 -... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
char s[N], out[N];
int a[N];
bool solve(int n) {
for (int l = 0, r = n - 1; l <= r; l++, r--) {
if (a[l] >= a[r] + 10) {
a[r - 1]--;
a[r] += 10;
}
if (a[l] == a[r] + 1) {
a[l]--;
a[l + 1] += 10;
}
if (a[l]... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
char s[100010];
char ans[100010];
int sum[100010];
int n;
bool check() {
for (int i = 0; i < n / 2;) {
if (sum[i] == sum[n - 1 - i])
++i;
else if (sum[i] == sum[n - 1 - i] + 1 ||
sum[i] == sum[n - 1 - i] + 10 + 1) {
sum[i]--;
sum[i + 1] += 10;
} else... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | import collections
import math
B = [int(x) for x in str(input())]
def solve(A):
A = A[::-1]
ans = [0] * 100010
r = len(A)
if r == 1:
return A[0] // 2 if A[0] % 2 == 0 else 0
for i in range(math.ceil(r / 2)):
#print(ans[:r], A, i, r - i - 1)
if i == r - i - 1:
... | PYTHON3 |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
string num;
int n[100 * 1000 + 100], l, r;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> num;
for (int i = 0; i < num.size(); ++i) n[i] = num[i] - '0';
l = 0, r = num.size() - 1;
if (n[l] != n[r]) {
n[l]--;
n[l + 1] += 10;
if (!n[l]) l... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
char s[100010];
int a[100010], ans[100010];
int main() {
memset(a, 0, sizeof(a));
memset(ans, 0, sizeof(ans));
scanf("%s", &s);
int n = strlen(s);
for (int i = 1; i <= n; i++) a[i] = s[i - 1] - '0';
int l = 1, r = n, flag = 1;
if (a[l] != a[r]) {
a[l]--;
... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
char str[100000 + 10];
char str1[100000 + 10];
char str2[100000 + 10];
char str3[100000 + 10];
int main() {
cin >> str;
int len = strlen(str);
if (str[0] == '1' && str[0] != str[len - 1]) {
for (int m = 0; m < len - 1; m++) {
str[m] = str[m + 1];
}
s... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class Main {
public static void main(String args[]) {
InputStream intputStream = System.in;
Out... | JAVA |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int dr[4][2] = {{0, 1}, {0, -1}, {-1, 0}, {1, 0}};
string s;
char ans[1000010];
int sum[1000010], n;
bool check() {
for (int i = 0; i < (n >> 1);) {
int l = i, r = n - 1 - i;
if (sum[l] == sum[r])
i++;
else if (sum[l] ==... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const long long int INF = (long long int)1e9 + 10;
const long long int INFLL = (long long int)1e18 + 10;
const long double EPS = 1e-10;
const long long int MOD = 1e9 + 7;
template <class T>
T &chmin(T &a, const T &b) {
return a = min(a, b);
}
template <class T>
T &chmax(T... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
char s[100022], t[100022];
int solve(char *s, char *t, int n) {
int i, j, c = 0, d = 0;
for (i = 0, j = n - 1; i < j; i++, j--) {
int a = s[i] + c * 10, b = s[j] - d;
if (b == -1) {
b += 10;
d = 1;
} else if (a >= b + 10) {
b += 10;
d... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 100;
char ss[N];
int aa[N];
int ans[N];
int dfs(int x, int y, int l, int r) {
if (x == y) {
if (l == 0 && r == 0 && aa[x] % 2 == 0) {
ans[x] = aa[x] / 2;
return 1;
}
if (l == 0 && r == 1 && aa[x] % 2 == 1) {
ans[x] = (aa[x... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | import java.util.*;
public class ProblemD2 {
private static String ans;
private static void pretreat(StringBuilder s){
for(int i = 0; i < s.length(); ++i){
if(s.charAt(i) != '0'){
s = s.delete(0, i);
... | JAVA |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
string n;
int a[100005], b[100005], c[100005], d[100005];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int l, m, rem, j;
bool tf;
cin >> n;
l = n.size();
b[0] = c[0] = d[0] = 0;
for (int i = 1; i <= l; i++) d[i] = (int)n[i - 1] - 48;
for (int i =... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
char s[maxn];
int n, t[maxn], a[maxn];
int b[20];
void init() {
for (int i = 0; i < 19; i++) {
b[i] = i < 10 ? i : (i - 9);
}
}
bool sol(int p, int l, int r) {
int i, val, bn = l;
for (i = l; i <= r; i++) t[i] = s[i] - '0';
while (l <... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
char s[100010];
char ans[100010];
int sum[100010];
int n;
bool check() {
for (int i = 0; i < n / 2;) {
if (sum[i] == sum[n - 1 - i])
++i;
else if (sum[i] == sum[n - 1 - i] + 1 ||
sum[i] == sum[n - 1 - i] + 10 + 1) {
sum[i]--;
sum[i + 1] += 10;
} else... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int maxn = 3e6;
const long long mod = 1e9 + 7;
const long double PI = acos((long double)-1);
long long pw(long long a, long long b, long long md = mod) {
long long res = 1;
while (b) {
if (b ... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int Maxn = 100005;
const int Maxd = 10;
char tmp[Maxn];
string n;
int dp[Maxn][2][2];
pair<int, int> my[Maxn][2][2];
pair<int, int> par[Maxn][2][2];
int Get(int l, int r, int fl1, int fl2) {
if (l > r) return 1;
if (!dp[l][fl1][fl2]) {
int res = -1;
if (l ... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
char __input[100001];
int N, a[100002];
bool Try() {
static int w[100002];
std::copy(a + 1, a + N + 1, w + 1);
int L = 1, R = N;
while (L < R - 1) {
if (w[R] - w[L] == 0)
;
else if (w[R] - w[L] == 10)
w[L] += 10, w[L + 1]--;
else if (w[R] - w[L] == 1)
w[R]-... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int N = 100010;
int T, n, op;
char ss[N];
int s[N], a[N];
bool find_it;
int dp[N][2][2];
int dfs(int l, int r, int nl, int nr) {
if (dp[l][nl][nr] != -1) return dp[l][nl][nr];
if (l > r) {
if (nl == nr && (a[l] + a[r] + nl) / 10 == ... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
template <typename T>
using Vector2D = std::vector<std::vector<T>>;
template <typename T>
using Vector3D = std::vector<Vector2D<T>>;
using PairInt = std::pair<int, int>;
using PairInt64 = std::pair<int64_t, int64_t>;
using MapInt = std::map<int, int>;
using MMapInt = std::multimap<int, int>;
us... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100030;
const long long MODD = 1000000009;
string s, t;
bool A[MAX_N][2][2];
void f(int lo, int hi, int c1, int c2) {
bool& x = A[lo][c1][c2];
if (x) return;
x = true;
if (lo > hi) {
if (c1 != c2) return;
cout << t << endl;
exit(0);
}... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int jilu[100050];
int ans[100050];
char from[100050];
int solve[100050];
int main() {
int pos = 0;
scanf("%s", from);
pos = strlen(from);
for (int i = 0; i < pos; i++) {
jilu[i] = from[i] - '0';
}
int l = 0, r = pos - 1;
int num = 0;
bool ok = (pos & 1);... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
char s[200000];
int a[200000];
int b[200000];
int n;
int m1, m2;
int dat[200000];
int suc;
int ma;
int type;
void pg(int x, int y) {
int i, j;
a[x] -= y;
for (i = x; i < n; i++) {
if (a[i] < 0)
a[i] += 10, a[i + 1]--;
else... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
char num[1000050];
int n[1000050];
char left[1000050];
int len;
bool Cout[1000050];
int ans[1000050];
bool check(int start) {
for (int i = start, j = len - 1; j >= i; j--, i++) {
int t1 = n[i] + 10 * Cout[i], t2 = n[j] + 10 * Cout[j];
if (t1 == t2 && t1 < 19) {
... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | import java.io.*;
import java.util.*;
public class D {
public static void solution(BufferedReader reader, PrintWriter out)
throws IOException {
In in = new In(reader);
String str = in.next();
s = str.toCharArray();
n = s.length;
a = new int[n];
visited = ... | JAVA |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int res[100010];
bool solve(int n, int *a) {
for (int i = 0; i < n / 2; i++) {
if (a[i] == a[n - i - 1])
continue;
else if (i + 1 == n - i - 1) {
if (a[i] == a[n - i - 1] + 11)
a[i]--, a[n - i - 1] += 10;
else
return 0;
} else... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 100100;
int A[MAXN];
int n;
char c[MAXN];
void load() {
scanf("%s", c);
n = strlen(c);
for (int i = 0; i < n; i++) A[i] = c[i] - '0';
}
int sol[MAXN];
bool solve() {
bool left_greater_than_nine = false;
bool right_plus_one = false;
int L = 0, R ... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
template <typename T>
inline int checkbit(T n, T i) {
return ((n >> i) & T(1));
}
inline int bits_count(int v) {
v = v - ((v >> 1) & 0x55555555);
v = (v & 0x33333333) + ((v >> 2) & 0x33333333);
return ((v + (v >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
}
inline int bits... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e9;
const long long LINF = (long long)1e18;
const long double PI = 2 * acos((long double)0);
long long gcd(long long a, long long b) {
long long r;
while (b != 0) {
r = a % b;
a = b;
b = r;
}
return a;
... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
char s[100010];
int a[100010];
int main() {
scanf("%s", s);
int len = strlen(s);
for (register int i = 0; i < len; ++i) a[i] = s[i] - '0';
int l = 0, r = len - 1;
if (a[l] != a[r]) {
a[l]--;
a[l + 1] += 10;
if (!a[l]) ++l;
}
while (l <= r) {
if... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
template <class T>
inline T lowbit(T x) {
return x & (-x);
}
template <class T>
inline T sqr(T x) {
return x * x;
}
template <class T>
inline bool scan(T &ret) {
char c;
int sgn;
if (c = getchar(), c == EOF) return 0;
while (c !=... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
const long long mod = 1000000000 + 7;
const double eps = 1e-6;
int n, m, x, y;
string s;
int a[maxn];
int main() {
cin >> s;
n = s.size();
for (int i = 0; i < n; i++) {
a[i] = s[i] - '0';
}
int l = 0, r = n - 1;
if (a[l] != a[r]) {... | CPP |
625_D. Finals in arithmetic | Vitya is studying in the third grade. During the last math lesson all the pupils wrote on arithmetic quiz. Vitya is a clever boy, so he managed to finish all the tasks pretty fast and Oksana Fillipovna gave him a new one, that is much harder.
Let's denote a flip operation of an integer as follows: number is considered... | 2 | 10 | import java.util.*;
public class ProblemD{
private static String ans;
private static void pretreat(StringBuilder s){
for(int i = 0; i < s.length(); ++i){
if(s.charAt(i) != '0'){
s = s.delete(0, i);
b... | JAVA |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.