text stringlengths 49 983k |
|---|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
int firstCake, secondCake;
cin >> n >> firstCake >> secondCake;
long long int max = 0;
for (size_t i = 1; i < n; i++) {
int minimum;
if ((int)(firstCake / i) < (int)(secondCake / (n - i)))
minimum = (int)(firstCake / i);
else
... |
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f, maxn = 1e5 + 100;
int ax[maxn], n, a, b;
bool calc(int x) {
if (x == 0) return false;
int ans1 = 0;
int temp1 = a, temp2 = b;
while (temp1 >= x) temp1 -= x, ans1++;
while (temp2 >= x) temp2 -= x, ans1++;
return ans1 < n;
}
int main() ... |
#include <bits/stdc++.h>
using namespace std;
void go() {
int i;
int c = 0;
for (i = 0; i < 1000; i++) {
c++;
}
}
int main() {
go();
int n, a, b, i, j;
cin >> n >> a >> b;
int l = n / 2;
int h = n / 2 + n % 2;
if (a <= b) swap(a, b);
int ans = 0;
for (i = 1; i < n; i++) {
j = n - i;
... |
#include <bits/stdc++.h>
using namespace std;
inline long long read() {
long long t = 0, f = 1;
char tmp = getchar();
while (tmp < '0' || tmp > '9') {
if (tmp == '-') f = -1;
tmp = getchar();
}
while (tmp >= '0' && tmp <= '9') t = t * 10 + tmp - 48, tmp = getchar();
return t * f;
}
int n, a, b;
int ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int o, n, x = 2, z, d, i, t, w, j, p, h, max = 0, y, k, m, l, r, q;
cin >> n >> m >> k;
int a[n];
for (i = 1, j = 0; i < n; i++, j++) {
l = m / i;
d = k / (n - i);
a[j] = l > d ? d : l;
}
sort(a, a + n - 1);
cout << a[n - 2];... |
#include <bits/stdc++.h>
using namespace std;
long long n, a, b;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >> a >> b;
long long ans = 0;
for (long long i = 1; i <= 5000000; i++) {
long long v1 = a / i;
long long v2 = b / i;
if (v1 == 0 || v2 == 0) continue;
if (v1 + v2 < n... |
#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int main() {
scanf("%d%d%d", &n, &m, &k);
int maxx = min(m, k);
for (int i = maxx; i >= 1; i--) {
int res = m / i + k / i;
if (res >= n) {
printf("%d", i);
break;
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using dd = long double;
namespace {
static bool constexpr dbg = 0;
ll constexpr N = -999;
ll n, a, b;
void init() { cin >> n >> a >> b; }
void solve() {
ll res = 1;
for (; res <= min(a, b); ++res) {
if (a / res + b / r... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, a, b;
cin >> n >> a >> b;
int x = a;
while ((a / x + b / x) < n) x--;
if (a < x)
cout << a;
else if (b < x)
cout << b;
else
cout << x;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, a, b, ts = 0;
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> a >> b;
int mx = 0;
for (int x = 1; x <= a + b; x++) {
if ((a / x) + (b / x) < n || x > b || x > a) {
cout << x - 1;
return 0;
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long int n, a, b, ans = INT_MIN;
cin >> n >> a >> b;
for (long long int i = 1; i < n; i++) ans = max(ans, min(a / i, b / (n - i)));
cout << ans << endl;
return 0;
}
|
#include <bits/stdc++.h>
long long cmpfunc(const void* a, const void* b) {
return (*(long long*)a - *(long long*)b);
}
int main(void) {
long long int test, i, j, n, count, flag = 0, o1 = 0, o2 = 0, b1, x, m, l,
max, sum2, min, f, c, r, o, sum1, sum = 0,
... |
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using vi = vector<int>;
int main() {
int n, a, b;
cin >> n >> a >> b;
int maxc = max(a, b), minc = min(a, b);
int mi = 0;
for (int i = 1; i < n; i++) {
int micur = min(i, n - i);
int macur = max(i, n - i);
if (min(maxc / macur... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, a, b, m;
cin >> n >> a >> b;
int najlepszywynik = 0;
for (int k = 1; k < n; k++) {
m = (min(a / k, b / (n - k)));
najlepszywynik = max(m, najlepszywynik);
}
cout << najlepszywynik << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, a, b, x;
cin >> n >> a >> b;
if (n == a + b)
cout << 1;
else {
int max = 0;
int x, y;
int min = 201;
int z, l;
for (int i = 1; i < n; i++) {
x = a / i;
y = b / (n - i);
if (x < y) {
min = x;
... |
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, a, b, ans = 0;
cin >> n >> a >> b;
for (int i = 0; i <= n; i++) {
long long x = i == 0 ? 0 : a / i;
long long y = i == n ? 0 : b / (n - i);
ans = max... |
#include <bits/stdc++.h>
using namespace std;
long long powm(long long base, long long exp, long long mod = 1000000007) {
long long ans = 1;
while (exp) {
if (exp & 1) ans = (ans * base) % mod;
exp >>= 1, base = (base * base) % mod;
}
return ans;
}
long long addm(long long a, long long b) {
long long ... |
#include <bits/stdc++.h>
using namespace std;
int n, a, b, ans = 0;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> a >> b;
for (int i = 1; i < n; i++) {
ans = max(ans, min(a / i, b / (n - i)));
}
cout << ans << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, a, b, mx = 0;
scanf("%d%d%d", &n, &a, &b);
for (int i = 1; i < n; i++) {
mx = max(mx, min(a / i, b / (n - i)));
}
printf("%d", mx);
}
|
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 998244353;
const double oula = 0.57721566490153286060651209;
using namespace std;
int n, a, b;
bool Check(int mid) {
int sum = a / mid;
sum += b / mid;
if (sum >= n) return true;
return false;
}
int main() {
std::ios::sync_with_stdio(false);
... |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n, a, b;
cin >> n >> a >> b;
long long ans = LONG_LONG_MIN;
for (long long i = 1; i < n; i++) {
long long one = i;
long long two = n - i;
ans = max(ans, min(a / one, b / two));
}
cout << ans << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000 * 1000 + 10;
int main() {
int n, a, b;
cin >> n >> a >> b;
int mx = 1;
for (int i = 1; i < n; i++) {
int x = a / i;
int y = b / (n - i);
if (min(x, y) > mx) mx = min(x, y);
}
cout << mx << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long nod1(long long a, long long b) { return a ? nod1(b % a, a) : b; }
long long nod(long long a, long long b) {
if (a > b) swap(a, b);
return nod1(a, b);
}
long long nok(long long a, long long b) { return a / nod(a, b) * b; }
long long sum(vector<int> v) {
long ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int n, a, b, i;
cin >> n >> a >> b;
long long int x, y, z, k = 0;
for (i = 1; i < n; i = i + 1) {
x = a / i;
y = b / (n - i);
z = min(x, y);
k = max(k, z);
}
cout << k << "\n";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int roundi(float d) { return floor(d + 0.5); }
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n, a, b;
cin >> n >> a >> b;
int ans = -1;
for (int i = 1; i < n; i++) {
ans = max(ans, min(a / i, b / (n - i)));
}
cout <<... |
#include <bits/stdc++.h>
using namespace std;
int n, a, b;
int chia(int pt, int s) { return s / pt; }
int main() {
scanf("%d %d %d", &n, &a, &b);
if (n == a + b) {
printf("1");
return 0;
}
int x, y, ans = 1;
for (int i = 1; i < n; i++) {
int j = n - i;
x = chia(i, a);
y = chia(j, b);
i... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
;
int n, a, b;
cin >> n >> a >> b;
if (n == a + b)
cout << 1;
else {
int st = 0, mx = 0;
for (int i = 1; i < n; i++) {
st = min(a / i, b / (n - i));
mx = max(st, mx);
... |
#include <bits/stdc++.h>
using namespace std;
int multitest = 0;
int n, a, b;
void input() { cin >> n >> a >> b; }
void solve() {
int ans = min(a, b / (n - 1));
for (int i = 1; i < n; i++) {
int z = a / i;
int zz = b / (n - i);
ans = max(ans, min(z, zz));
}
cout << ans << '\n';
}
int main() {
if (... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, a, b, ans = 0;
cin >> n >> a >> b;
for (int i = 1; i < n; i++) {
int tmp = min(a / i, b / (n - i));
ans = max(ans, tmp);
}
cout << ans;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, a, b, i;
cin >> n >> a >> b;
long long int x = -1;
for (i = 1; i < n; ++i) {
long long int temp = min(a / i, b / (n - i));
x = max(x, temp);
}
cout << x;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
signed main() {
long long n, a, b;
cin >> n >> a >> b;
long long ans = -1;
for (long long i = 1; i < min(a, b) + 1; ++i) {
if (max(a / i, (long long)1) + max(b / i, (long long)1) >= n) ans = i;
}
if (ans == -1) {
cout << 0;
return 0;
}
cout << an... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
long long n, a, b;
cin >> n >> a >> b;
long long ans = 1;
for (int i = 1; i <= min(a, b); i++) {
if (((a / i) + (b / i)) >= n) {
ans = i;
}
}
cout << ans << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
inline void timer(void) { cout << clock() / CLOCKS_PER_SEC; }
int main() {
int n, a, b, x = 0;
cin >> n >> a >> b;
for (int i = 1; i < n; i++) {
int la = i, lb = n - i;
x = ((x > ((a / la > b / lb) ? b / lb : a / la))
? x
: ((a / la >... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, a, b;
cin >> n >> a >> b;
int l = 1, r = max(a, b);
while (r - l > 0) {
int mid = l + (r - l + 1) / 2;
int v = (a / mid) + (b / mid);
if (v > n - 1 && a / mid > 0 && b / mid > 0) {
l = mid;
} else {
r = mid - 1;
}
... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, a, b;
while (cin >> n >> a >> b) {
int Max = 0;
for (int i = 1; i < n; i++) {
int ret = n - i;
Max = max(Max, min(b / ret, a / i));
}
cout << Max << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
bool ok(int mid, int a, int b, int n) {
if (a / mid + b / mid < n)
return false;
else
return true;
}
int main() {
int n, a, b;
int low, high;
cin >> n >> a >> b;
if (a < b)
low = 1, high = a;
else
low = 1, high = b;
while (low < high) {
i... |
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
int main() {
ios_base::sync_with_stdio();
cin.tie();
cout.tie();
int n, a, b, ans = 1;
cin >> n >> a >> b;
while (a / ans + b / ans >= n && ans <= a && ans <= b) ans++;
cout << --ans;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, a, b;
cin >> n >> a >> b;
int ans = -1;
for (int i = 1; i <= n - 1; i++) {
for (int k = 1; true; k++) {
if (i * k <= a && (n - i) * k <= b)
ans = max(ans, k);
else
break;
}
}
cout << ans << endl;
return 0... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t, a, b;
cin >> t >> a >> b;
int ans = 0;
for (int i = 1; i < t; i++) {
ans = max(ans, min(a / i, b / (t - i)));
}
cout << ans << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, a, b;
cin >> n >> a >> b;
int x;
for (x = 1; x <= (a + b) / n; x++) {
if (a / x + b / x < n || a / x == 0 || b / x == 0) {
break;
}
}
x--;
cout << x;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cer... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, a, b;
scanf("%d %d %d", &n, &a, &b);
if (a > b) {
swap(a, b);
}
int ans = 0, x = n;
for (int i = 1; i <= a; i++) {
x -= (a / i);
if (x != 0) {
ans = max(ans, min(i, b / x));
}
x = n;
}
printf("%d\n", ans);
}
|
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
int n;
char s[1000010], t[1000010];
struct PAM {
struct node {
int Next[26];
int fail;
int len;
int diff, anc;
long long f;
node(int _len = 0) {
memset(Next, 0, sizeof Next);
fail = 0;
diff = anc = 0... |
#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T &x) {
x = 0;
char c = getchar(), f = 0;
for (; c < 48 || c > 59; c = getchar())
if (!(c ^ 45)) f = 1;
for (; c >= 48 && c <= 57; c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
f ? x = -x : 0;
}
const int P = 1e9 + 7... |
#include <bits/stdc++.h>
char aa[1 + 1000000 + 1];
int tt[2 + 1000000][26], fff[2 + 1000000][26], ff[2 + 1000000],
ff_[2 + 1000000], len[2 + 1000000], diff[2 + 1000000], dp_[2 + 1000000];
int node(int l) {
static int _;
len[_] = l;
return _++;
}
void init() {
int a;
node(0), node(-1);
aa[0] = -1;
for ... |
#include <bits/stdc++.h>
using namespace std;
int const mod = 1e9 + 7;
int const MAXN = 1e6 + 5;
char s[MAXN], t[MAXN];
int child[MAXN << 1][26], parent[MAXN << 1], mxlen[MAXN << 1], cnt = 2,
last = 1;
int d[MAXN << 1], bot[MAXN << 1];
int f[MAXN], g[MAXN <... |
#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T& x) {
char c = getchar();
bool f = false;
for (x = 0; !isdigit(c); c = getchar()) {
if (c == '-') {
f = true;
}
}
for (; isdigit(c); c = getchar()) {
x = x * 10 + c - '0';
}
if (f) {
x = -x;
}
}
... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
const long long mm = 1e9 + 7;
int ch[maxn][27], fail[maxn];
long long cnt[maxn];
long long s[maxn], len[maxn];
int slink[maxn];
int dif[maxn];
char sp[maxn];
long long g[maxn];
int last, sz, n;
int newnode(int x) {
for (int i = 0; i < 26; ++i) {... |
#include <bits/stdc++.h>
long long read() {
long long x = 0, f = 1;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-') f = -1;
c = getchar();
}
while (c >= '0' && c <= '9') x = x * 10 + (c - '0'), c = getchar();
return f * x;
}
long long max(long long a, long long b) { return a > b ? a :... |
#include <bits/stdc++.h>
using namespace std;
const int maxn(1e6 + 5);
const int mod(1e9 + 7);
inline void Inc(int &x, int y) {
if ((x += y) >= mod) x -= mod;
}
int n, f[maxn], diff[maxn], anc[maxn], g[maxn];
int fa[maxn], len[maxn], trans[26][maxn], tot, last;
char s[maxn], tmp[maxn];
inline void Extend(int c, int p... |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 10, MAXM = 4e6 + 10;
const int INF = INT_MAX, SINF = 0x3f3f3f3f;
const long long llINF = LLONG_MAX;
const int MOD = 1e9 + 7, mod = 119;
const int Lim = 1 << 20;
struct PAM {
int sz, tot, last;
int ch[MAXN][26], len[MAXN], fail[MAXN];
int cnt[MAX... |
#include <bits/stdc++.h>
using namespace std;
const int N = 5 + 1e6, MOD = 1e9 + 7;
inline void mo(int& x) { x >= MOD ? x -= MOD : 0; }
inline int mo1(int x) { return x >= MOD ? x - MOD : x; }
struct Ari {
int l, r, d;
};
struct Pam {
struct Node {
int s[26], fa, len, top, delta;
} t[N];
int top;
inline i... |
#include <bits/stdc++.h>
using namespace std;
char ch[1000010], Ch[1000010];
int n;
long long F[1000010], S[1000010];
int C[1000010][26], Pr[1000010], Sz[1000010], D[1000010], Pl[1000010],
cnt = 1, l = 1, tot = 0;
int getp(int x) {
for (; Ch[tot - Sz[x] - 1] != Ch[tot]; x = Pr[x])
;
return x;
}
void add(int... |
#include <bits/stdc++.h>
const int N = 1e6 + 5, md = 1e9 + 7;
char t[N], s[N];
int n, k, ch[N][26], len[N], lst, fail[N], tot, fa[N], dlt[N];
int ans[N], f[N];
inline void upd(int& a) { a += a >> 31 & md; }
void ins(int pos) {
int p = lst, c = s[pos] - 'a';
while (s[pos] != s[pos - len[p] - 1]) p = fail[p];
if (!... |
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
int g[1000010], f[1000010], trans[1000010][26];
int fail[1000010], len[1000010];
char st[1000010];
int c[1000010];
int d[1000010], pos[1000010];
int n, lst, cnt;
inline int mo(int x) {
if (x >= MOD) return x - MOD;
return x;
}
int getfail(int... |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000005;
string s;
struct PalindromicTree {
int N, cur;
vector<map<int, int>> next;
vector<int> link, start, len, diff, slink;
PalindromicTree() : N(0), cur(0) {
node();
len[0] = -1;
node();
}
int node() {
next.emplace_back();
... |
#include <bits/stdc++.h>
char S[1000000 + 5], T[1000000 + 5];
int c[1000000 + 5][26], l[1000000 + 5], f[1000000 + 5], tn, df[1000000 + 5],
ff[1000000 + 5], s[1000000 + 5], F[1000000 + 5];
int main() {
int n, i, j, x;
scanf("%s", S + 1);
n = strlen(S + 1);
T[0] = 255;
for (i = 1; i <= n / 2; ++i)
T[2 *... |
#include <bits/stdc++.h>
class Palindrome_Automaton {
private:
static const int MAXS = 1e6, MOD = 1e9 + 7;
int Cnt, Last, Aux[MAXS + 5], F[MAXS + 5], Dif[MAXS + 5], Anc[MAXS + 5];
struct Node {
int L, Fa, Ch[26];
Node() {}
Node(const int l, const int f = 0) {
L = l, Fa = f;
for (register ... |
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
template <typename T>
inline void Read(T &x) {
char c = getchar();
bool f = false;
for (x = 0; !isdigit(c); c = getchar()) {
if (c == '-') {
f = true;
}
}
for (; isdigit(c); c = getchar()) {
x = x * 10 + c - '0';
}
... |
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int maxn = 1e6;
long long ans;
long long pw[maxn + 5];
char s[maxn + 5], t[maxn + 5];
struct Palindromic_Tree {
int ch[maxn + 5][26];
int s[maxn + 5];
int fail[maxn + 5];
int cnt[maxn + 5];
int num[maxn + 5];
int len[maxn + 5... |
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
char S[1000005];
char S2[1000005];
int N, ind, cur, Serial[1000005], DP[1000005], suff;
struct PTree {
int suf, next[26], len, slink, diff;
} Palind[1000005];
void initTree() {
cur = suff = 2;
Palind[1].suf = 1;
Palind[1].len = -1;
Pali... |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000010;
const int MOD = 1e9 + 7;
inline int add(int a, int b) { return (a += b) >= MOD ? a - MOD : a; }
inline void inc(int& a, int b) { a = add(a, b); }
struct PAM {
struct node {
int ch[26], fail, len, dif, anc;
} t[MAXN];
int totn, lst;
inli... |
#include <bits/stdc++.h>
using namespace std;
const int N = 1000000 + 2;
const int M = 1000000007;
const int A = 26;
void add(int &a, int b) {
a += b;
if (a >= M) {
a -= M;
}
}
int series_link[N], series[N], diff[N];
int link[N], length[N], to[N][A];
string t;
int get(int u, int i) {
while (true) {
int ... |
#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int N = 1e6 + 100;
const int mod = 1e9 + 7;
char s[N], t[N], cnt;
int n;
long long f[N], g[N];
struct Palindrome_tree {
int nxt[N][26];
int fail[N];
int len[N];
int cnt[N];
int sed[N];
int record[N];
int diff[N], anc[N];
cha... |
#include <bits/stdc++.h>
using namespace std;
const int N = 1234567, mod = 1e9 + 7;
void add(int& x, int y) {
x += y;
if (x >= mod) {
x -= mod;
}
}
int n, last, tt, ch[N][26], father[N], len[N], diff[N], anc[N], sum[N], dp[N];
string r, s, t;
int new_node(int from) {
len[++tt] = len[from] + 2;
return tt;
... |
#include <bits/stdc++.h>
using namespace std;
const int Imx = 2147483647;
const long long Lbig = 2e18;
const int mod = 1e9 + 7;
const int maxn = 1000111;
char s[maxn];
int n, tot, go[maxn][26], fail[maxn], slink[maxn], len[maxn], dlen[maxn];
int st[maxn];
int append(int p, int l) {
int c = s[l] - 'a';
while (s[l - ... |
#include <bits/stdc++.h>
using namespace std;
int n, s[1000005], top[1000005], f[1000005], g[1000005];
int c[1000005][26], F[1000005], len[1000005], cnt, pos[1000005];
char str[1000005];
int main() {
scanf("%s", str + 1);
n = strlen(str + 1);
s[0] = -1;
for (int i = 1; i <= n / 2; i++) {
s[i * 2 - 1] = str[... |
#include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
const int mod = 1e9 + 7;
namespace pam {
int ch[N][26], fail[N], dif[N], slink[N], cnt[N], dep[N], len[N];
int sz, tot, lst;
char s[N];
int new_node(int lenn) {
++sz;
memset(ch[sz], 0, sizeof(ch[sz]));
len[sz] = lenn;
cnt[sz] = dep[sz] = fail[... |
#include <bits/stdc++.h>
using namespace std;
long long p1 = 1000000, p2 = 0;
char buf[1000005], wb[1000005];
long long gc() {
if (p1 >= 1000000) fread(buf, 1, 1000000, stdin), p1 = 0;
return buf[p1++];
}
long long getint() {
long long ret = 0, flag = 1;
char c = getchar();
while (c < '0' || c > '9') {
if... |
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
template <typename T>
inline void Add(T &x, T y) {
x += y;
if (x >= mod) x -= mod;
}
namespace PAM {
int ne[1000010][26], fail[1000010], len[1000010], las, cnt, n, d[1000010],
anc[1000010], t[1000010];
long long info[1000010];
void ini... |
#include <bits/stdc++.h>
using namespace std;
template <typename... As>
struct tpl : public std::tuple<As...> {
using std::tuple<As...>::tuple;
tpl() {}
tpl(std::tuple<As...> const& b) { std::tuple<As...>::operator=(b); }
template <typename T = tuple<As...> >
typename tuple_element<0, T>::type const& x() cons... |
#include <bits/stdc++.h>
using namespace std;
inline int read() {
int x = 0, f = 1;
char ch = getchar();
while (!isdigit(ch)) {
if (ch == '-') f = -1;
ch = getchar();
}
while (isdigit(ch)) {
x = x * 10 + ch - '0';
ch = getchar();
}
return x * f;
}
const int MAXN = 1000006, Mo = 1e9 + 7;
na... |
#include <bits/stdc++.h>
using namespace std;
const int mod = 1E9 + 7;
const int maxn = 1E6 + 77;
struct Node {
int s, d, c;
int last() { return (d == -1) ? (s) : (s + d * (c - 1)); }
} G[maxn], aux[maxn];
int cg = 0, caux = 0;
char SS[maxn], S[maxn];
int L;
long long dp[maxn], F[maxn];
int main() {
scanf("%s", S... |
#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const long long inf64 = 1e18;
const int mod = inf + 7;
inline int _sum(int a, int b) { return a + b < mod ? a + b : a + b - mod; }
inline int _mul(int a, int b) { return (1ll * a * b) % mod; }
inline int _sub(int a, int b) { return a >= b ? a - b : a - ... |
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
inline int read() {
int w = 1, s = 0;
char ch = getchar();
while (!isdigit(ch)) {
if (ch == '-') w = -1;
ch = getchar();
}
while (isdigit(ch)) {
s = s * 10 + ch - '0';
ch = getchar();
}
return w * s;
}
int n, diff[20101... |
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void read(T &x) {
int f = 0;
x = 0;
char ch = getchar();
for (; !isdigit(ch); ch = getchar()) f |= (ch == '-');
for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
if (f) x = -x;
}
const int mod = 1e9 + 7;
int fix(int x) { return... |
#include <bits/stdc++.h>
using namespace std;
const int N = 1001000, P = 1e9 + 7;
int n, cnt, x, y, u;
int Fa[N], s[N][30], l[N], fa[N], tp[N];
int p[N], f[N], g[N], ok[N], d[N];
char S[N], T[N];
void ins(int c, int p) {
for (x = y; S[p] != S[p - l[x] - 1]; x = Fa[x])
;
if (s[x][c]) return y = s[x][c], void();
... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1100000;
const int mod = 1e9 + 7;
int n, m;
char S[maxn];
int str[maxn];
int id[maxn], f[maxn], g[maxn];
struct pTree {
int fail[maxn], trans[maxn][26], diff[maxn], nxt[maxn], len[maxn];
int cnt, last;
void init() {
cnt = 1;
last = 0;
mems... |
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("-Ofast")
#pragma GCC target( \
"sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx2,tune=native")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-funroll-loops")
const int N = 1e6 + 17;
const int mod = 1e9 + 7;
int n;
const int base = 31... |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 7;
int MOD = 1e9 + 7;
namespace PAM {
int scnt, S[MAXN];
int pcnt, last, len[MAXN], fail[MAXN], ch[MAXN][26];
int cnt[MAXN], num[MAXN], trans[MAXN], diff[MAXN], slink[MAXN];
int newnode(int _len) {
len[pcnt] = _len;
cnt[pcnt] = num[pcnt] = 0;
fo... |
#include <bits/stdc++.h>
inline long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
inline void sub(long long &a, long long b) {
a -= b;
if (a < 0) a += 1000000007;
}
inline void add(long long &a, long long b) {
a += b;
if (a >= 1000000007) a -= 1000000007;
}
template <typename T>
inline T... |
#include <bits/stdc++.h>
using namespace std;
template <class T>
T read() {
T x = 0, w = 1;
char c = getchar();
for (; !isdigit(c); c = getchar())
if (c == '-') w = -w;
for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
return x * w;
}
template <class T>
inline T read(T& x) {
return x = read<T>();
... |
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int n, f[1000005], g[1000005];
char s[1000005], s2[1000005];
namespace PAM {
int fa[1000005] = {1, 1}, ch[1000005][26], len[1000005] = {0, -1}, last, sz = 1,
anc[1000005], dif[1000005];
void extend(int x) {
int p = last, c = s[x] - 'a';
whil... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = (int)1e6 + 1, maxl = maxn, mod = (int)1e9 + 7;
int n, m, sta[maxl], dif[maxl], cnt[maxl], f[maxn], g[maxn];
char buf[maxn], str[maxn];
inline void mod_inc(int &x, int y) { (x += y) >= mod && (x -= mod); }
int main() {
scanf("%s", buf + 1);
n = strlen(bu... |
#include <bits/stdc++.h>
using namespace std;
inline void proc_status() {
ifstream t("/proc/self/status");
cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>())
<< endl;
}
template <typename T>
inline bool chkmin(T &a, const T &b) {
return a > b ? a = b, 1 : 0;
}
template <typename T>
i... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2000010;
const int mod = 1e9 + 7;
const int MAX = 1000000010;
const double eps = 1e-6;
const double PI = acos(-1);
template <typename T>
inline void read(T &x) {
x = 0;
T f = 1;
char ch;
do {
ch = getchar();
if (ch == '-') f = -1;
} while ... |
#include <bits/stdc++.h>
using namespace std;
const int C = 26, N = 1e6 + 5, MOD = 1e9 + 7;
struct node {
node *child[C], *fail, *slink;
int length, cnt, diff, series;
node(int length) : fail(NULL), slink(NULL), length(length) {
memset(child, NULL, sizeof(child));
cnt = diff = series = 0;
}
};
int size,... |
#include <bits/stdc++.h>
using namespace std;
template <typename... As>
struct tpl : public std::tuple<As...> {
using std::tuple<As...>::tuple;
tpl() {}
tpl(std::tuple<As...> const& b) { std::tuple<As...>::operator=(b); }
template <typename T = tuple<As...> >
typename tuple_element<0, T>::type const& x() cons... |
#include <bits/stdc++.h>
using namespace std;
int const mod = 1e9 + 7;
int const MAXN = 1e6 + 5;
char s[MAXN], t[MAXN];
int child[MAXN << 1][26], parent[MAXN << 1], mxlen[MAXN << 1], cnt = 2,
last = 1;
int d[MAXN << 1], bot[MAXN << 1], even[MAXN << 1];
int ... |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxn = 1 << 20, mod = 1e9 + 7;
int len[maxn], diff[maxn], link[maxn], slink[maxn];
map<int, int> to[maxn];
int sz, cur;
basic_string<int> s;
void init() {
len[0] = -1;
sz = 2, cur = 0;
}
bool bad(int v) {
return (int)s.size() - len[v] -... |
#include <bits/stdc++.h>
const int P = 1000000007;
inline int mul(const int &a, const int &b) { return 1ll * a * b % P; }
inline int add(int a, const int &b) {
a += b;
return (a >= P) ? a - P : a;
}
inline int sub(int a, const int &b) {
a -= b;
return (a < 0) ? a + P : a;
}
int n, s[1000001], son[1000001][26], ... |
#include <bits/stdc++.h>
using namespace std;
int n, K;
struct PAM {
struct node {
int ch[26];
int len, fail;
int dif, slink;
} t[2000000 + 5];
int ptr = 0, last = 0;
char *str;
void ini(char *in) {
str = in;
ptr = 1;
(t[0].fail) = 1;
(t[1].len) = -1;
}
int get_fail(int x, int ... |
#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int N = 1e6 + 7;
const int M = N << 1;
long long mod = 1e9 + 7;
struct pam {
int t[N][26], fa[N], len[N], rs[N], cnt[N], num[N];
int dif[N], slink[N];
int sz, n, last;
int _new(int l) {
len[sz] = l;
cnt[sz] = num[sz] = 0;
... |
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T Tmin(const T &lch, const T &rch) {
if (lch < rch) return lch;
return rch;
}
template <class T>
inline T Tmax(const T &lch, const T &rch) {
if (lch < rch) return rch;
return lch;
}
const int Inf = 0x3f3f3f3f;
const int Mod = 1e9 + 7;
const... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1100000;
const int MOD = 1000000007;
char t[maxn], s[maxn];
int fail[maxn], len[maxn], nxt[maxn][26], diff[maxn], slink[maxn], n, p, last;
int newnode(int l) {
len[p] = l;
return p++;
}
void init() {
p = 0;
newnode(0);
newnode(-1);
fail[last = 0... |
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 1000000 + 5;
inline int add(int x, int y) {
x += y;
return x >= mod ? x -= mod : x;
}
namespace pam {
int sz, tot, last;
int ch[maxn][26], len[maxn], fail[maxn];
int cnt[maxn], dep[maxn], dif[maxn], slink[maxn];
char s[maxn];
in... |
#include <bits/stdc++.h>
using namespace std;
int ch[1000005][26];
int fail[1000005], len[1000005];
int d[1000005], nxt[1000005];
int tot, last2, now;
void init() {
tot = last2 = 1;
len[1] = -1;
fail[0] = 1;
}
char str[1000005];
int getfail(int x) {
while (str[now] != str[now - len[x] - 1]) x = fail[x];
retur... |
#include <bits/stdc++.h>
using namespace std;
const int P = 1000000007;
int add(int a, int b) {
int r = a + b;
return r < P ? r : r - P;
}
int sub(int a, int b) {
int r = a - b;
return r < 0 ? r + P : r;
}
namespace pam {
char s[1 << 20];
int g[1 << 20][26], f[1 << 20], l[1 << 20], d[1 << 20], t[1 << 20], nc;
i... |
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void read(T &x) {
x = 0;
char c = getchar();
int f = 1;
while (!isdigit(c)) {
if (c == '-') f = -1;
c = getchar();
}
while (isdigit(c)) x = x * 10 - '0' + c, c = getchar();
x *= f;
}
const int N = 1e6 + 10, mod = 1e9 + 7;
int ... |
#include <bits/stdc++.h>
using namespace std;
const int Imx = 2147483647;
const long long Lbig = 2e18;
const int mod = 1e9 + 7;
struct fastio {
char s[100000];
int it, len;
fastio() { it = len = 0; }
inline char get() {
if (it < len) return s[it++];
it = 0;
len = fread(s, 1, 100000, stdin);
if (... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.