text stringlengths 49 983k |
|---|
#include <bits/stdc++.h>
using namespace std;
char s[1010000];
int main() {
int i, j, k, m, n;
scanf("%s", s);
n = strlen(s);
if (n % 2 == 1) {
n = (n + 1) / 2;
for (i = 1; i <= n; i++) putchar('4');
for (i = 1; i <= n; i++) putchar('7');
puts("");
} else {
char u = '7';
int flag = 0;
... |
#include <bits/stdc++.h>
using namespace std;
int n, hn;
string s, r, c;
int c1[100005], c2[100005];
string times(string s, int t) {
c = "";
for (int i = 0; i < t; ++i) c += s;
return c;
}
inline void work(int w) {
cout << r.substr(0, w + 1) + times("4", hn - c1[w]) + times("7", hn - c2[w]) +
'\n'... |
#include <bits/stdc++.h>
using namespace std;
string n;
string mini = "7777777777777777";
void bt(string s) {
if (s.size() == n.size() + 4) return;
bt(s + '4');
bt(s + '7');
long long f = 0, sev = 0;
for (int i = 0; i < s.size(); i++) {
if (s[i] == '4')
f++;
else
sev++;
}
if (f != sev)... |
#include <bits/stdc++.h>
char str[1000000], s1[1000000];
int n;
int main() {
int i, j, c, flag = 0;
scanf("%s", str);
n = strlen(str);
if (n % 2 == 1) flag = 1;
for (i = j = c = 0; i < n && i + abs(j) <= n && !flag && !c; i++) {
if (str[i] < '4')
c = 1, s1[i] = '4', j++;
else if (str[i] == '4')
... |
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
int len = s.length();
if (len % 2) {
for (int i = 0; i <= len / 2; ++i) cout << 4;
for (int i = 0; i <= len / 2; ++i) cout << 7;
return 0;
}
string res = "9999999999";
string t;
for (int i = 0; i < len / 2; ++i) t... |
#include <bits/stdc++.h>
using namespace std;
int n, x, y, d, O4[100005], O7[100005], S4[100005], S7[100005];
char s[100005];
int tooLarge() {
for (int i = 0; i < n / 2; i++) {
if (s[i] > '7') return -1;
if (s[i] < '7') return i;
}
for (int i = n / 2; i < n; i++) {
if (s[i] > '4') return -1;
if (s... |
#include <bits/stdc++.h>
using namespace std;
char s[1000010];
string ans = "";
bool cal(int &a, int &b) {
int x = -1;
int y = -1;
for (int j = ans.size() - 1; j >= 0; j--) {
if (ans[j] == '7') {
x = j;
break;
}
}
if (x == -1) {
return false;
}
for (int j = x - 1; j >= 0; j--) {
... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
char aa[maxn], bb[maxn];
int a[maxn], b[maxn];
int main() {
scanf("%s", aa);
int len = strlen(aa);
if (len % 2) {
len++;
for (int i = 1; i <= len / 2; i++) {
printf("4");
}
for (int i = 1; i <= len / 2; i++) {
pri... |
#include <bits/stdc++.h>
using namespace std;
int main() {
string a;
getline(cin, a);
vector<int> b(a.size());
for (int i = 0; i < a.size(); ++i) b[i] = a[i] - '0';
bool big = false, back;
int pos = 0, c4 = b.size() / 2;
int c7 = c4;
if (b.size() % 2 == 1) goto out;
while (true) {
back = false;
... |
#include <bits/stdc++.h>
int tc(char a) { return a - int('0'); }
using namespace std;
int main() {
string st;
cin >> st;
int n = st.size();
if (n & 1) {
for (int i = 0; i < n / 2 + 1; i++) cout << '4';
for (int i = 0; i < n / 2 + 1; i++) cout << '7';
cout << endl;
return 0;
}
bool convertir ... |
#include <bits/stdc++.h>
char a[100004];
char b[100004];
int make(char b[], int len) {
int i, j, k;
while (1) {
k = 0;
for (i = 0; i < len; i++)
if (b[i] == '7') k++;
if (k == len / 2)
return 0;
else if (k < len / 2) {
for (i = len - 1; i >= 0; i--) {
if (b[i] == '4') k++;
... |
#include <bits/stdc++.h>
using namespace std;
const double pi = 4.0 * atan(1.0);
int64_t num;
queue<int64_t> qu;
bool ifgood(int64_t x) {
int64_t a, b;
a = 0;
b = 0;
while (x) {
if (x % 10 == 4)
++a;
else if (x % 10 == 7)
++b;
else
return false;
x /= 10;
}
if (a == b) retur... |
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const double pi = 3.141592653589793238462643383279;
void solve() {
long long num;
cin >> num;
long long dig = log10(num) + 1, i = 0;
string ans = "";
while (i < dig / 2) ans += "47", i++;
if (dig & 1) ans += "47";
sort((ans).begin(), (... |
#include <bits/stdc++.h>
using namespace std;
int main() {
string a;
getline(cin, a);
deque<int> b(a.size());
for (int i = 0; i < a.size(); ++i) b[i] = a[i] - '0';
bool big = false, back = false;
int pos = 0, c4 = b.size() / 2;
int c7 = c4;
if (b.size() % 2 == 1) goto out;
while (true) {
back = fa... |
#include <bits/stdc++.h>
using namespace std;
vector<long long> all;
void backtrack(long long cur, int cnt4, int cnt7) {
if (cur > 1e10) return;
if (cnt4 == cnt7) all.push_back(cur);
long long nxt = cur * 10 + 4;
backtrack(nxt, cnt4 + 1, cnt7);
nxt = cur * 10 + 7;
backtrack(nxt, cnt4, cnt7 + 1);
}
int main(... |
#include <bits/stdc++.h>
using namespace std;
const int MX = 32000000;
const long long INF = 1E18 + 7;
vector<int> pr;
map<long long, vector<long long>> fct, dst;
int t;
long long n, k;
bool chk[MX];
struct SNode {
long long u, val;
};
inline bool operator<(const SNode &a, const SNode &b) { return a.val < b.val; }
pr... |
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10, M = 55, S = 31624000;
long long T, n, k;
namespace gp {
bool isprime[S];
long long t = 0, prime[20 * N];
void getprime() {
memset(isprime, 0, sizeof(isprime));
for (int i = 2; i < S; i++) {
if (!isprime[i]) prime[++t] = i;
for (int j = 1;... |
#include <bits/stdc++.h>
using namespace std;
inline long long Qmul(const long long &x, const long long &y,
const long long &X) {
long long k = (long long)((1.0L * x * y) / (1.0L * X)), t = x * y - k * X;
t -= X;
while (t < 0) t += X;
return t;
}
class MillerRabin {
private:
const int P... |
#include <bits/stdc++.h>
using namespace std;
template <typename T>
void chkmax(T &x, T y) {
x = x > y ? x : y;
}
template <typename T>
void chkmin(T &x, T y) {
x = x > y ? y : x;
}
const long long INF = (1ull << 62);
template <typename T>
void read(T &x) {
x = 0;
bool f = 1;
char ch;
do {
ch = getchar(... |
#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const int MAXT = (int)1e4 + 3;
const int MAXN = (int)31700000;
const int MAXP = (int)1e5 + 3;
const int infint = (int)2e9;
const long long inf = (long long)2e18;
int T;
long long n[MAXT], k[MAXT], dist[MAXP];
bool prime[MAXN], ans[MAXT];
vector... |
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7, M = 31700000;
struct query {
long long n, k;
int id;
} q[N];
int t, cnt, qs, qe, l, ans[N], vis[M], pri[M], que[N * 20];
long long p[N], f[N];
bool cmp(query a, query b) { return a.k < b.k; }
long long qpow(long long a, long long b, long long mod)... |
#include <bits/stdc++.h>
using namespace std;
int t, dis[100000];
vector<int> primes;
map<long long, vector<pair<long long, int>>> mp;
bool vis[100000], composite[32000000], res[10000];
vector<pair<int, int>> adj[100000];
void modifiedEuclid(long long f1, long long f2, long long &m1, long long &m2) {
if (f1 == 0) {
... |
#include <bits/stdc++.h>
using namespace std;
map<long long, int> m;
map<long long, int>::iterator it;
const int times = 7;
int number = 0;
int n, low, high, mid, prime[100000], cnt_p, mi[100000], list[2][111111],
cnt_list[2], pos[110000];
long long a[110000], xx, yy, ds;
bool is[110000];
int ex[111111];
long long ... |
#include <bits/stdc++.h>
using namespace std;
long long int t;
map<long long int, vector<pair<long long int, long long int>>> qur;
bool p[32000000];
vector<long long int> primes;
vector<pair<long long int, long long int>> adj[1000005];
long long int dist[1000005];
set<pair<long long int, long long int>> s;
string ans[1... |
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int M = 4e7 + 5;
long long n, k;
map<long long, int> IM;
int tot = 0;
vector<long long> s[N];
int ID(long long x) {
if (IM.count(x)) return IM[x];
IM[x] = ++tot;
return -1;
}
int p[M], cnt;
bool vis[M];
void init() {
for (int i = (2); i ... |
#include <bits/stdc++.h>
using namespace std;
int pr[6000005], cnt, target[5000005], pre[5000005], last[100005], tot;
bool flag[31622780], ans[50005], visited[100005], flag2;
long long dis[100005], w[5000005];
vector<long long> v;
struct query {
long long n, k;
int id;
} c[50005];
bool cmp(query x, query y) { retur... |
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long INFF = 0x3f3f3f3f3f3f3f3fll;
const long long M = 1e9 + 7;
const long long maxn = 3e6 + 7;
const double pi = acos(-1.0);
const double eps = 0.00000001;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
templ... |
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long powmod(long long a, long long b) {
long long res = 1;
a %= mod;
assert(b >= 0);
for (; b; b >>= 1) {
if (b & 1) res = res * a % mod;
a = a * a % mod;
}
return res;
}
int gcd(int a, int b) { return b ? gcd(b, a ... |
#include <bits/stdc++.h>
using namespace std;
const long long T = 1e4, SQ = 32e6, inf = 1e18 + 10;
bool notprime[SQ], ans[T];
vector<int> primes;
map<long long, vector<pair<long long, int> > > mapk;
long long euclid(long long x, long long y, long long &z1, long long &z2) {
if (y == 0) {
z1 = 1;
z2 = 0;
re... |
#include <bits/stdc++.h>
using namespace std;
const int T = 11000;
long long N[T], M[T];
int id[T];
bool ans[T];
namespace Factor {
const int MAXN = 2000005;
const int CERTAINTY = 8;
const int RUNS = 20;
int maxn, prn;
int p[MAXN], prm[MAXN];
vector<long long> d;
long long fac[110];
long long q[110], e[110];
long long ... |
#include <bits/stdc++.h>
using namespace std;
const long long INF = (long long)1e9 * (long long)1e9;
const int T = 1e4 + 10, SQ = 32 * 1e6, N = 1e5 + 10;
long long n[T], k[T], dp[N];
int ans[T], q;
vector<int> cheat;
bitset<SQ> not_prime;
long long power(long long a, long long b, long long mod) {
if (b == 0) return 1... |
#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
const int M = 4e7;
int pr[M / 10];
int prSz = 0;
bool np[M];
long long mod;
long long mul(long long a, long long b) {
a %= mod;
b %= mod;
long long q = (long long)(1.0 * a * b / mod);
long long r = a * b - q * mod;
r %= mod;
if (r < 0) r +... |
#include <bits/stdc++.h>
using namespace std;
int pri[9] = {2, 3, 5, 7, 11, 13, 15, 17, 23}, cnt = 0;
long long seed = 2001071221701002ll, ans[66];
inline long long rnd() {
seed ^= (seed << 13ll);
seed ^= (seed >> 17ll);
seed ^= (seed << 5ll);
return (seed < 0 ? -seed : seed);
}
inline void add(long long &a, lo... |
#include <bits/stdc++.h>
using namespace std;
const long long maxn = 100010, inf = 1e9;
map<long long, long long> mp;
struct poi {
long long x;
long long dis;
};
priority_queue<poi> q;
bool operator<(poi a, poi b) { return a.dis > b.dis; }
struct edge {
long long too;
long long dis;
long long pre;
} e[maxn * ... |
#include <bits/stdc++.h>
using namespace std;
const int tmax = 1e4 + 42, MX = 32e6, K_MAX = 1e5 + 42;
struct query {
long long n, k;
int id;
};
bool cmp(query a, query b) { return a.k < b.k; }
int t;
query inp[tmax];
bitset<MX> is_prime;
vector<int> primes;
void prec() {
int p = 2;
while (p * p < MX) {
for ... |
#include <bits/stdc++.h>
const int N = 31623000;
using namespace std;
bool fl[N];
int pri[2000000], tot;
void init() {
for (int i = 2; i < N; i++) {
if (!fl[i]) pri[++tot] = i;
for (int j = 1; i * pri[j] < N; j++) {
fl[i * pri[j]] = 1;
if (i % pri[j] == 0) break;
}
}
}
long long mul(long lon... |
#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 long long maxn = 4e6 + 5;
long long pri[maxn], cnt;
bool p[maxn * 9];
long long P;
void init() {
for (long long i = 2; i <= P; ++i) {
if (!p[i]) pri[++cnt] = i;
for (long long j = 1; j <= cnt && i * pri[j] <= P; ++j) {
p[i * pri[j]] = 1;
if (i % ... |
#include <bits/stdc++.h>
using namespace std;
int t, cnt, ans, pr[32000010], tot;
bool p[32000010], an[100010];
long long f[100010], inf = 1e18 + 7, d[100];
struct qu {
long long n, m;
int id;
bool operator<(qu const &a) const { return m < a.m; }
} q[100010];
struct node {
int s;
long long v;
node(int _s = ... |
#include <bits/stdc++.h>
using namespace std;
const int N = 10003, M = 31622800, K = 1952000, L = 100003;
template <typename T>
inline void read(T &x) {
int ch = getchar();
x = 0;
bool f = false;
for (; ch < '0' || ch > '9'; ch = getchar()) f |= ch == '-';
for (; ch >= '0' && ch <= '9'; ch = getchar()) x = x ... |
#include <bits/stdc++.h>
using namespace std;
map<long long, vector<pair<long long, int>>> mapchik;
const long long INF = (long long)2e18;
const int M = (int)35e6;
const int PSZ = (int)3e6;
bool p[M];
int pr[PSZ];
int prSz;
const int N = (int)1e5 + 10;
bool ANS[N];
long long dist[N];
long long euclid(long long x, long ... |
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("avx")
#pragma GCC target("sse,sse2,sse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
template <typename T>
int sgn(T val) {
return (T(0) < val) - (val < T(0));
}
long long read() {
long long x = 0;
bool q =... |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
const int MAXM = 50000007;
const long long INF = 0x3f3f3f3f3f3f3f3f;
template <typename T>
inline void read(T &AKNOI) {
T x = 0, flag = 1;
char ch = getchar();
while (!isdigit(ch)) {
if (ch == '-') flag = -1;
ch = getchar();
}
whil... |
#include <bits/stdc++.h>
using namespace std;
long long f[100100];
int pr[31600000], t, p[100100], l, que[100100 * 20], head, tail;
bool bz[31600000], ans[100100], vis[100100];
struct qry {
long long n, k, w;
} q[100100];
bool cmp(qry a, qry b) { return a.k < b.k; }
long long qpow(long long a, long long i, long long ... |
#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
const long long inf = (long long)2e18;
int ed, T, ans[10005], fir[N];
long long que[66], dis[N];
struct Edge {
int v, nxt;
long long w;
} e[N * 66];
struct Info {
long long n, k;
int id;
bool operator<(const Info& x) const { return k < x.k; }... |
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
using std::abs;
using std::cerr;
using std::cin;
using std::cout;
using std::map;
using std::max;
using std::min;
using std::pair;
using std::set;
using std::string;
using std::swap;
using std::vector;
u... |
#include <bits/stdc++.h>
using namespace std;
inline void read(int &x) {
int v = 0, f = 1;
char c = getchar();
while (!isdigit(c) && c != '-') c = getchar();
if (c == '-')
f = -1;
else
v = (c & 15);
while (isdigit(c = getchar())) v = (v << 1) + (v << 3) + (c & 15);
x = v * f;
}
inline void read(lo... |
#include <bits/stdc++.h>
template <typename T>
inline void read(T &x) {
x = 0;
char c = getchar();
while (!isdigit(c)) c = getchar();
while (isdigit(c)) x = x * 10 + (c ^ 48), c = getchar();
}
using namespace std;
int t;
int pri[4001000], pcnt;
bool depri[35001000];
inline void init() {
depri[1] = true;
con... |
#include <bits/stdc++.h>
using namespace std;
long long mulmod(long long a, long long b, long long c) {
long long sign = 1;
if (a < 0) {
a = -a;
sign = -sign;
}
if (b < 0) {
b = -b;
sign = -sign;
}
a %= c;
b %= c;
long long res = 0;
while (b > 0) {
if (b & 1) {
res = (res + a... |
#include <bits/stdc++.h>
using namespace std;
int get() {
char ch;
while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-')
;
if (ch == '-') {
int s = 0;
while (ch = getchar(), ch >= '0' && ch <= '9') s = s * 10 + ch - '0';
return -s;
}
int s = ch - '0';
while (ch = getchar(), ch >= '0' &... |
#include <bits/stdc++.h>
using namespace std;
const int MAXK = 60;
const int MAXT = 1E4 + 10;
const int LIM = 1E5 + 10;
namespace Pollard_Rho {
const int pr[] = {2, 3, 5, 7, 11, 23, 43, 79};
const int M = (1 << 8) - 1;
mt19937 RandEngine(chrono::steady_clock::now().time_since_epoch().count());
long long RandInt(long lo... |
#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 1e18;
const long long MAXK = 1e15;
const long long INF = 4e18;
const int MAXV = 3.2e7 + 5;
const int MAXP = 2e6 + 10;
const int MAXF = 1e5 + 10;
const int MAXQ = 50;
const int MAXLOG = 64;
long long n, k, tot, q;
int f[MAXV], prime[MAXP], cnt[MAXQ + 1... |
#include <bits/stdc++.h>
using namespace std;
template <class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& p) {
return o << "(" << p.first << "," << p.second << ")";
}
template <class T>
ostream& operator<<(ostream& o, const vector<T>& vc) {
o << "sz = " << vc.size() << endl << "[";
for (const T&... |
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long powmod(long long a, long long b) {
long long res = 1;
a %= mod;
assert(b >= 0);
for (; b; b >>= 1) {
if (b & 1) res = res * a % mod;
a = a * a % mod;
}
return res;
}
int gcd(int a, int b) { return b ? gcd(b, a ... |
#include <bits/stdc++.h>
const int N = 32000010;
const int M = 10010;
int min[N];
int prime[2000010], pcnt;
bool ans[M];
bool dp[N];
void init() {
for (int i = 2; i < N; ++i) {
if (!min[i]) {
min[i] = i;
prime[pcnt++] = i;
}
for (int j = 0; j < pcnt && i * prime[j] < N; ++j) {
min[i * pr... |
#include <bits/stdc++.h>
using namespace std;
const long long INF = (long long)2e18;
const int MAXN = (int)1e4 + 5;
const int P = (int)3e7 + (int)3e6;
const int M = (int)1e5;
pair<pair<long long, long long>, int> req[MAXN];
vector<int> primes;
bool isP[P + 5];
bool ans[MAXN];
long long dp[M + 5];
int q;
void pre() {
... |
#include <bits/stdc++.h>
using namespace std;
const int MAX_P = 40000010, N = 10010, MAX_N = 100010;
const long long inf = 1e17;
int p[MAX_P], t, ans[N];
map<long long, vector<pair<long long, int> > > M;
inline void Pre(const int &n) {
for (int i = 2; i <= n; i++) {
if (!p[i]) p[++*p] = i;
for (int j = 1; j <... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010, maxm = 35000000;
int T, tot, p[maxm];
long long n, k, dist[maxn];
bool ans[maxn];
map<long long, vector<pair<long long, int> > > mp;
void exgcd(long long a, long long b, long long &x, long long &y) {
if (!b) {
x = 1, y = 0;
return;
}
e... |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<long long, long long>;
const long long MAX = 10004, M2 = 1e5 + 10, K = 4e7 + 5;
const long long inf = 0x3f3f3f3f;
void minn(long long &a, long long b) {
if (b < a) a = b;
}
void maxx(long long &a, long long b) {
if (b > a) a = b;
}
... |
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long INFF = 0x3f3f3f3f3f3f3f3fll;
const long long M = 1e9 + 7;
const long long maxn = 3e6 + 7;
const double pi = acos(-1.0);
const double eps = 0.00000001;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
templ... |
#include <bits/stdc++.h>
using namespace std;
const int N = 10003, M = 31622800, K = 1952000, L = 100003;
template <typename T>
inline void read(T &x) {
int ch = getchar();
x = 0;
bool f = false;
for (; ch < '0' || ch > '9'; ch = getchar()) f |= ch == '-';
for (; ch >= '0' && ch <= '9'; ch = getchar()) x = x ... |
#include <bits/stdc++.h>
using namespace std;
const int MAXQ = 55;
const int MAXLOG = 64;
const int MAXN = 100005;
const int MAXP = 2e6 + 5;
const int MAXV = 3.2e7 + 5;
const long long INF = 4e18;
template <typename T>
void chkmax(T &x, T y) {
x = max(x, y);
}
template <typename T>
void chkmin(T &x, T y) {
x = min(... |
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5, B = 32e6;
const long long inf = 1e17;
int p[N * 50], nump;
bool np[B + 5];
long long n, k, pr[105], cnt, d[N];
bool vis[N], ans[N];
struct data {
long long n, k;
int id;
} Q[N];
priority_queue<pair<long long, int> > q;
bool cmp(data a, data b) { r... |
#include <bits/stdc++.h>
using namespace std;
const int N = 4e7 + 10;
bool isprime[N];
vector<int> prime;
const int M = 1e5 + 10;
int dis[55][M];
vector<int> factor[55];
bool vis[M];
vector<pair<int, long long> > edge[M];
map<long long, int> ma;
void init(int n) {
memset(isprime, true, sizeof(isprime));
isprime[1] ... |
#include <bits/stdc++.h>
using namespace std;
const long long N = 3.5e7 + 9, M = 1e5 + 9, kkk = 53;
const long long INF = 0x3f3f3f3f;
long long n, K, T, cnt, num[kkk];
long long prime[3000009], tot, p[kkk][109];
long long dis[kkk][M], been[kkk];
bool isprime[N], vis[M];
priority_queue<pair<long long, long long> > Q;
in... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
int T, tot, p[3000010];
long long n, k, dist[maxn];
bool ok[35000000], ans[maxn];
map<long long, vector<pair<long long, int> > > mp;
void exgcd(long long a, long long b, long long &x, long long &y) {
if (!b) {
x = 1, y = 0;
return;
}
e... |
#include <bits/stdc++.h>
using namespace std;
const int MAXK = 60;
const int MAXT = 1E4 + 10;
const int LIM = 1E5 + 10;
namespace Pollard_Rho {
const int pr[] = {2, 3, 5, 7, 11, 23, 43, 79};
const int M = (1 << 8) - 1;
mt19937 RandEngine(chrono::steady_clock::now().time_since_epoch().count());
long long RandInt(long lo... |
#include <bits/stdc++.h>
using namespace std;
const int T_MAX = 10005;
const int SIEVE_MAX = 32000000;
const int SMALL_MAX = 100005;
const long long LL_INF = 2e18;
struct video {
long long n, k;
int index;
bool operator<(const video &other) const {
return make_pair(k, n) < make_pair(other.k, other.n);
}
};
... |
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chkmin(T& x, T y) {
return x > y ? x = y, true : false;
}
template <class T>
inline bool chkmax(T& x, T y) {
return x < y ? x = y, true : false;
}
const long long MAXN = 1e18;
const long long MAXK = 1e15;
const long long INF = 4e18;
const ... |
#include <bits/stdc++.h>
using namespace std;
template <typename TP>
inline void read(TP &ret) {
TP x = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
x = x * 10 + ch - '0';
ch = getchar();
}
ret = (TP)x * f;
}
int t;
struct nod... |
#include <bits/stdc++.h>
using namespace std;
const long long inf = 2000000000000000000;
const int maxn = 10000 + 10;
struct dong {
long long n, k;
int id;
friend bool operator<(dong a, dong b) { return a.k < b.k; }
} ask[maxn];
long long f[100000 + 10], p[50];
int pri[5000000 + 10];
bool bz[32000000 + 10], pd[10... |
#include <bits/stdc++.h>
using namespace std;
bool np[33000000], inq[100010], b;
long long n, k, dis[55][100010], p[55][33000000 / 15 / 6];
int prime[33000000 / 15], num, cnt[55], now, total;
queue<int> q;
map<long long, int> mp;
inline int getint() {
char c = getchar();
int x;
bool p;
x = p = 0;
while ((c < ... |
#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &x) {
x = 0;
bool f = 0;
char c = getchar();
for (; !isdigit(c); c = getchar())
if (c == '-') f = 1;
for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
if (f) x = -x;
}
template <typename F>
inline void write(F x, char... |
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
const int maxt = 10010;
const int maxn = 100010;
int T;
long long q_n[maxt], q_k[maxt];
int p_list[10000010], isnp[40000010], tot;
vector<long long> vec;
map<long long, int> k_id;
long long mul(long long a, long long b, long long mod) {
long lo... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010, maxm = 33333333, m = 32000000, mod = 998244353;
inline long long read() {
char ch = getchar();
long long x = 0, f = 0;
while (ch < '0' || ch > '9') f |= ch == '-', ch = getchar();
while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = ge... |
#include <bits/stdc++.h>
using std::map;
using std::priority_queue;
const int KV2 = 56, S = 32000000;
map<long long, int> mi;
int mar;
long long pr[2333333], pi;
bool vis[S + 1];
void sieve() {
for (long long i = 2; i <= S; i++) {
if (!vis[i]) pr[++pi] = i;
for (int j = 1; j <= pi && pr[j] * i <= S; j++) {
... |
#include <bits/stdc++.h>
using namespace std;
vector<int> primes;
vector<int> smallestPrimeFactor;
void linearSieve(int n) {
if (n < 1) n = 1;
if ((int)smallestPrimeFactor.size() >= n + 1) return;
int primePiBound = n < 20 ? n - 1 : (int)(n / (log(n * 1.) - 2) + 2);
primes.assign(primePiBound + 1, numeric_limit... |
#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 1e18;
const long long MAXK = 1e15;
const long long INF = 4e18;
const int MAXV = 3.2e7 + 5;
const int MAXP = 2e6 + 10;
const int MAXF = 1e5 + 10;
const int MAXQ = 50;
const int MAXLOG = 64;
long long n, k, tot, q;
int f[MAXV], prime[MAXP], cnt[MAXQ + 1... |
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long powmod(long long a, long long b) {
long long res = 1;
a %= mod;
assert(b >= 0);
for (; b; b >>= 1) {
if (b & 1) res = res * a % mod;
a = a * a % mod;
}
return res;
}
long long gcd(long long a, long long b) { re... |
#include <bits/stdc++.h>
using namespace std;
const int MXP = 4e7;
bitset<MXP> prime;
vector<long long> primes;
void sieve() {
for (int p = 2; p < MXP; p++) {
if (prime[p]) continue;
primes.push_back(p);
for (int q = p; q < MXP; q += p) prime.set(q);
}
}
map<long long, vector<pair<long long, int>>> qry;... |
#include <bits/stdc++.h>
using namespace std;
inline long long gcd(long long x, long long y) {
return (x % y == 0) ? y : gcd(y, x % y);
}
long long mul(long long x, long long y, long long MOD) {
long long ans = 0;
while (y) {
if (y & 1) ans = (ans + x) % MOD;
x = (x + x) % MOD;
y >>= 1;
}
return a... |
#include <bits/stdc++.h>
const int MX = 33333333;
using namespace std;
int n, cnt, p[2100000], pc, v[51];
bitset<MX> Prime;
map<long long, int> Map;
vector<long long> d[51];
int R[51][101000];
long long Pow(long long a, long long b, long long Mod) {
long long r = 1;
while (b) {
if (b & 1) r = r * a % Mod;
a... |
#include <bits/stdc++.h>
#pragma GCC optimize("O2,Ofast,inline,unroll-all-loops,-ffast-math")
#pragma GCC target("popcnt")
using namespace std;
struct que {
int id;
long long n, k;
bool operator<(const que &rhs) const { return k < rhs.k; }
} qs[10010];
struct cmp {
bool operator()(const pair<int, long long> &A,... |
#include <bits/stdc++.h>
const int N = 2000005, M = 55, S = 31624000;
int t;
long long n, k;
int pri[N], cnt;
bool vis[S + 10];
void euler(void) {
vis[1] = 1;
for (int i = 2; i < S; ++i) {
if (!vis[i]) pri[++cnt] = i;
for (int j = 1; j <= cnt && i * pri[j] < S; ++j) {
vis[i * pri[j]] = 1;
if (!i... |
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5, M = 3e5 + 5;
int T, p[2000000], cnt, m, edgenum, Head[N], Next[M], vet[M];
bool isnp[32000001], vis[N], ans[N];
long long n, k, K[55], d[20], val[M], dis[N], X, Y;
vector<pair<long long, int> > vec[55];
priority_queue<pair<long long, int>, vector<pair... |
#include <bits/stdc++.h>
using namespace std;
template <typename T>
void maxtt(T &t1, T t2) {
t1 = max(t1, t2);
}
template <typename T>
void mintt(T &t1, T t2) {
t1 = min(t1, t2);
}
bool debug = 0;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
string direc = "RDLU";
long long ln, lk, lm;
void etp(b... |
#include <bits/stdc++.h>
using namespace std;
inline void read(int &x) {
x = 0;
char c = getchar();
int f = 1;
while (!isdigit(c)) {
if (c == '-') f = -1;
c = getchar();
}
while (isdigit(c)) {
x = x * 10 + c - '0';
c = getchar();
}
x *= f;
}
inline unsigned int R() {
static unsigned in... |
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10, M = 3.3e7;
int prm[M], tot;
void init(int n) {
for (int i = 2; i <= n; i++) {
if (!prm[i]) prm[++tot] = i;
for (int j = 1; j <= tot && i * prm[j] <= n; ++j) {
prm[i * prm[j]] = true;
if (i % prm[j] == 0) break;
}
}
}
struc... |
#include <bits/stdc++.h>
using namespace std;
const long long MXP = 31622800, INF = 1ll << 62;
long long t, n, k, dist[100 * 1000 + 10];
vector<long long> p, pk;
bool b[MXP], ans[10 * 1000 + 10];
vector<pair<long long, long long>> sv;
void primes() {
for (long long i = 2; i < MXP; i++)
if (!b[i]) {
p.push_b... |
#include <bits/stdc++.h>
using namespace std;
pair<pair<long long int, long long int>, int> queries[10000];
bitset<32000000> bs;
vector<int> primes;
long long int dist[100000];
priority_queue<pair<long long int, int> > H;
int ans[10000];
int main() {
int i;
int t;
long long int n, k;
scanf("%d", &t);
for (i =... |
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void in(T &x) {
x = 0;
char c = getchar();
bool f = 0;
while (!isdigit(c)) f |= (c == '-'), c = getchar();
while (isdigit(c)) x = x * 10 + (c ^ '0'), c = getchar();
f ? x = -x : 0;
}
template <class T>
inline void out(T x, const char c ... |
#include <bits/stdc++.h>
using namespace std;
template <typename Tp>
inline void read(Tp &x) {
static char c;
static bool neg;
x = 0, c = getchar(), neg = false;
for (; !isdigit(c); c = getchar()) {
if (c == '-') {
neg = true;
}
}
for (; isdigit(c); c = getchar()) {
x = x * 10 + c - '0';
... |
#include <bits/stdc++.h>
using namespace std;
namespace SHENZHEBEI {
static const int GYN = 2333333;
char SZB[GYN], *SS = SZB, *TT = SZB;
inline char gc() {
if (SS == TT) {
TT = (SS = SZB) + fread(SZB, 1, GYN, stdin);
if (SS == TT) return '\n';
}
return *SS++;
}
inline long long read() {
long long x = 0... |
#include <bits/stdc++.h>
using namespace std;
inline long long read() {
long long x = 0, f = 1, c = getchar();
while (c < 48) c == '-' && (f = -1), c = getchar();
while (c > 47) x = x * 10 + c - '0', c = getchar();
return x * f;
}
const int MAXN = 100005;
const int LIM = 31622779;
struct qs {
long long n, k, ... |
#include <bits/stdc++.h>
using namespace std;
struct Query {
long long n, k;
int pos;
} Q[10005];
int M;
bool V[32000005];
int Prime[32000005];
vector<long long> Div;
int Heap[100005], NHeap, Pos[100005];
bool Res[10005];
bool Use[100005];
long long D[100005];
void Sieve() {
for (int i = 2; 1LL * i * i <= 1000000... |
#include <bits/stdc++.h>
using namespace std;
const int T_MAX = 10005;
const int SIEVE_MAX = 32000000;
const int SMALL_MAX = 100005;
const long long LL_INF = 2e18;
struct video {
long long n, k;
int index;
bool operator<(const video &other) const {
return make_pair(k, n) < make_pair(other.k, other.n);
}
};
... |
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
using namespace std;
const long long maxn = 1e5 + 123, inf = 1e9, N = 3e7 + 5e6, INF = 1e18,
mod = 1e9 + 7;
vector<pair<long long, long long> > v, g[maxn];
vector<long long> prime;
bool used[N + 13];
lo... |
#include <bits/stdc++.h>
using namespace std;
int t;
map<int, int> has;
long long fj[55][50], gs[55], bh;
long long n, k;
const long long S = 31624000;
const long long mf = 1e5 + 10;
bool is[S];
long long p[2000000];
void init() {
for (int i = 2; i < S; i++) {
if (!is[i]) p[++p[0]] = i;
for (int j = 1; j <= p... |
#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 5;
long long nn[N], kk[N];
map<long long, vector<int> > M;
vector<long long> pr;
bool res[N];
long long egcd(long long a, long long b, long long &x, long long &y) {
if (b == 0) {
x = 1;
y = 0;
return a;
}
long long x1, y1;
long long g... |
#include <bits/stdc++.h>
using namespace std;
const long long INF = 4e18;
const int BASE = 131;
const double eps = 1e-4;
const int mod = 998244353;
const int inf = 1061109567;
const double pi = acos(-1);
const int inv2 = (mod + 1) >> 1;
namespace Math {
inline long long popcount(long long x) {
x = (x & 0x55555555) + ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.