solution stringlengths 53 181k | difficulty int64 0 13 |
|---|---|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, sum = 0, sum1 = 0, prev = 0;
int h[1000001];
cin >> n;
for (int i = 0; i < n; i++) {
cin >> h[i];
}
for (int i = 0; i < n; ++i) {
{
sum1 += abs(prev - h[i]);
prev = h[i];
}
}
sum = sum1 + n + (n - 1);
cout << sum... | 1 |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5005, MAXM = 500005;
struct Edge {
int from, to;
int val;
int id;
Edge(int from = 0, int to = 0, int val = 0, int id = 0)
: from(from), to(to), val(val), id(id) {}
bool operator<(const Edge& b) const {
if (val != b.val) return val < b.va... | 8 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int a, b, c, d, e, f, g, h, i, j, k, l, m, n;
long long int maximum, minimum, answer = 0;
cin >> a >> b;
while (a > 0 && b > 0 && (a + b) > 2) {
if (a > b) {
a = a - 2;
b = b - 1;
answer++;
} else {
b = b - 2;
... | 2 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
int a[n];
for (int i = 0; i < n; i++) {
cin >> a[i];
}
for (int i = n - 1; i >= 0; i--) {
if (i >= n / 2) {
cout << (-1) * a[i] << " ";
} else {
a[i]... | 0 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int x;
cin >> x;
while (x) {
x++;
if (x % 10 != (x / 10) % 10 && x % 10 != (x / 100) % 10 &&
x % 10 != (x / 100) % 10 && x % 10 != (x / 1000) % 10 &&
(x / 10) % 10 != (x / 100) % 10 && (x / 10) % 10 != (x / 1000) % 10 &&
(x... | 0 |
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;
int n, q, a[N];
long long f[N], s[N];
bool cmp(const int &x, const int &y) { return x > y; }
long long solve(int k) {
if (~f[k]) return f[k];
long long ret = 0, t = 0, p = 1;
for (int i = 2, j; i <= n; i = j) {
++t, p = p * k;
j = min((l... | 5 |
#include <bits/stdc++.h>
using namespace std;
const int N = 100 * 1000 + 5, LG = 20;
vector<pair<int, int> > chld[N];
vector<pair<pair<int, int>, int> > q3;
vector<pair<int, int> > q2;
int par[N][LG], dp[N][LG];
int h[N], indeg[N];
void dfs(int v) {
for (auto p : chld[v]) {
int u = p.first, w = p.second;
h[u]... | 6 |
#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
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;
}
struct node {
... | 8 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long tc, o;
cin >> tc;
for (o = 1; o <= tc; o++) {
long long n, a, b, c, p, sm = 0, i, j, flg = 0;
vector<long long> v;
map<long long, long long> mp;
scanf("%lld", &n);
for (i = 0; i < n; i++) {
scanf("%lld", &a);
v.pu... | 1 |
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
long long powmod(long long a, long long b, long long MOD) {
if (a == 0ll) {
return 0ll;
}
a %= MOD;
long long ans = 1;... | 1 |
#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 1;
int n, m;
vector<int> adj[N];
bool vis[N];
vector<int> all[N];
int dep[N];
int par[N];
int pairs = 0;
bool outputted = 0;
void dfs(int u) {
if (outputted) return;
vis[u] = 1;
pairs -= all[dep[u]].size() / 2;
all[dep[u]].push_back(u);
pairs +... | 9 |
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
const int MOD = 1e9 + 7;
const double PI = 2 * acos(0.0);
int main() {
int n;
cin >> n;
double ans = 0;
for (int i = n; i >= 1; i--) {
double x = 1.0 / (double)i;
ans += x;
}
cout << fixed << setprecision(10) << ans << endl;
retu... | 1 |
#include <bits/stdc++.h>
using namespace std;
const int maxn = (int)1e6 + 100;
const int mod = (int)1e9 + 7;
string second;
int n, sum, ans, cnt, K = 200000, t[maxn];
int ok(char ch) {
ch = tolower(ch);
if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u') return 1;
return 0;
}
void upd(int pos, int ... | 6 |
#include <bits/stdc++.h>
using namespace std;
int b[110][110] = {0};
bool comp(pair<int, int> a, pair<int, int> b) { return a.first < b.first; }
int main() {
int n, m, u, v;
cin >> n >> m;
int* arr = new int[n];
for (int i = 0; i < n; i++) cin >> arr[i];
vector<pair<int, int> > vec;
for (int i = 0; i < m; i... | 2 |
#include <bits/stdc++.h>
using namespace std;
int dx[8] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy[8] = {1, -1, 0, -1, 1, 1, 0, -1};
int main() {
ios::sync_with_stdio(false);
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
;
long long n, t1, t2, s1, s2;
double k;
cin >> n >> t1 >> t2 >> k;
vecto... | 2 |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 165;
const int MAXJZ = 16;
int n, t, len;
int lim[MAXJZ];
char dic[MAXJZ];
long long C[MAXN][MAXN], dp[MAXN][MAXN];
int Read() {
int x = 0, f = 1;
char c = getchar();
while (c > '9' || c < '0') {
if (c == '-') f = -1;
c = getchar();
}
whil... | 8 |
#include <bits/stdc++.h>
using namespace std;
vector<int> ans;
const int maxn = 3 * 1e5 + 10;
bool ok[maxn];
int main() {
int t, n, m;
cin >> t;
while (t--) {
ans.clear();
scanf("%d", &n), scanf("%d", &m);
int x, y;
for (int i = 1; i <= 3 * n; i++) ok[i] = false;
for (int i = 1; i <= m; i++) {... | 6 |
#include <bits/stdc++.h>
using namespace std;
char buffer[100000], *p1, *p2;
template <class T>
void read(T& x) {
char ch = ((p1 == p2 &&
(p2 = (p1 = buffer) + fread(buffer, 1, 100000, stdin), p1 == p2))
? EOF
: *p1++);
x = 0;
bool f = 1;
while (!('0' <= ch && ch ... | 9 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long m, n;
map<long long, long long> mpa, mpb;
vector<int> v;
cin >> n;
long long a, x, b, y;
for (int i = 0; i < n; i++) {
cin >> a >> x;
mpa[a] = x;
v.push_back(a);
}
cin >> m;
for (int i = 0; i < m; i++) {
cin >> b >> y... | 1 |
#include <bits/stdc++.h>
using namespace std;
int a[200005], k[200005], nowk[200005];
int main() {
ios::sync_with_stdio(false);
int n, m, ans = -1, sum = 0;
int l = 1, r = 0, now = 0;
cin >> n >> m;
for (int i = 1; i <= n; i++) cin >> a[i];
for (int i = 1; i <= m; i++) {
cin >> k[i];
if (k[i] == 0) ... | 3 |
#include <bits/stdc++.h>
using namespace std;
const int MOD = 7000007, sd = 37;
int n, sq, now, sum, hs[500005];
char tmp[500005];
bitset<500005> f[1001];
bitset<7000010> b;
int md(int x) { return x >= MOD ? x - MOD : x; }
int main() {
scanf("%d%s", &n, tmp + 1);
for (int i = 1; i <= n; i++) hs[i] = tmp[i] - 'a' + ... | 12 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, l, r, Ql, Qr;
cin >> n >> l >> r >> Ql >> Qr;
vector<int> w(n);
for (int i = 0; i < n; ++i) cin >> w[i];
long long answer = 0;
for (int i = 0; i < n; ++i) answer += w[i] * l + Ql;
answer -= Ql;
long long curanswer = answer;
for (int i =... | 3 |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100000 + 10, L = 18;
int n, m, a[MAXN];
set<int> s[L];
int main() {
cin >> n >> m;
for (int i = 0; i < L; ++i) s[i].insert(0), s[i].insert(n + 1);
for (int i = 1; i <= n; ++i) {
cin >> a[i];
for (int j = 0; j < L; ++j)
if (!(a[i] & (1 <<... | 6 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
float a[n];
float p[n];
float price = 1000;
int tprice = 0;
for (int i = 0; i < n; i++) {
cin >> a[i];
cin >> p[i];
price = min(price, p[i]);
tprice += price * a[i];
}
cout << tprice;
return 0;
}
| 0 |
#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
const long long int inf = 1e18;
long long int n, last = 0, ans = 0;
vector<pair<long long int, long long int>> arr;
map<long double, vector<pair<long long int, long long int>>> brr;
vector<vector<pair<long long int, long long int>>> crr(
... | 5 |
#include <bits/stdc++.h>
using namespace std;
struct comp {
bool operator()(const pair<char, int>& a, const pair<char, int>& b) {
if (a.first != b.first) return a.first < b.first;
return a.second > b.second;
}
};
int counts[26];
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
string s;
m... | 5 |
#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
bool comp(string a, string b) {
if (a.length() != b.length()) return a.length() > b.length();
return a >= b;
}
int main() {
char s[100005];
scanf("%s", &s);
string tmp = "";
vector<s... | 4 |
#include <bits/stdc++.h>
using namespace std;
int a[1001];
int main() {
int n;
cin >> n;
int m = n * n;
for (int r = 1, t = m; r <= n; r++, t--) {
for (int i = r, j = t, k = 1; k <= (n / 2); i += n, j -= n, k++) {
cout << i << " " << j << " ";
}
cout << endl;
}
return 0;
}
| 1 |
#include <bits/stdc++.h>
using namespace std;
const int Maxn = 100005;
const int Maxm = 2097152;
const int Maxk = 20;
const int Inf = 2000000007;
int n, k;
int b[Maxn][Maxk];
int q;
int typ[Maxn], lef[Maxn], rig[Maxn], x[Maxn];
vector<int> un, seq, vals;
int st[Maxm], flag[Maxm];
int Get(int l, int r) {
int res = Inf... | 7 |
#include <bits/stdc++.h>
using namespace std;
long long n, m;
int t;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> t;
while (t--) {
cin >> n >> m;
int xu[2], yu[2], xd[2], yd[2];
for (int i = 0; i < 2; i++) {
cin >> xd[i] >> yd[i] >> xu[i] >> yu[i];
}
lon... | 3 |
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
void solve() {
int n, t;
double p;
cin >> n >> p >> t;
double dp[t + 1][n + 1];
for (int i = 0; i <= t; i++) {
for (int j = 0; j <= n; j++) dp[i][j] = 0;
}
dp[0][0] = 1;
for (int i = 0; i < t; i++) {
for (int j = 0; j <= n; j... | 4 |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 3000 + 10;
int n, ans = 0;
string s;
int a[maxn] = {};
int main() {
ios ::sync_with_stdio(false);
cin.tie(0);
cin >> n >> s;
int ii = 0;
while (ii < n && s[ii] == '.') ans++, ii++;
if (ii < n && s[ii] == 'L') ans = 0;
for (int i = 0; i < n; i+... | 1 |
#include <bits/stdc++.h>
using namespace std;
int countSteps(int m, int n, int init) {
assert(n >= m);
if (n == m) {
if (n == 1)
return init;
else
return 2000000;
} else {
int a = n - m;
if (a > m)
return countSteps(m, a, init + 1);
else
return countSteps(a, m, init + 1... | 5 |
#include <bits/stdc++.h>
using namespace std;
inline int getInt() {
int x;
scanf("%d", &x);
return x;
}
const int maxn = 1e5 + 5;
int a[maxn];
int e[maxn][2];
map<int, int> pos;
bool good[maxn][2];
int v[2];
bool res;
vector<pair<int, int> > vs;
bool color[maxn];
int was[maxn];
int main() {
int n;
scanf("%d%d... | 6 |
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
while(t--){
int n;
cin >> n;
int arr[n];
int eq;
for(int i=0;i<n;i++){
cin >> arr[i];
}
eq = 0;
int eq2;
for(int i=1;i<n;i++){
if(arr[i] != ... | 0 |
#include <bits/stdc++.h>
using namespace std;
template <class T>
using vec = vector<T>;
template <typename Iter>
ostream& _IterOutput_(ostream& o, Iter b, Iter e, const string ss = "",
const string se = "") {
o << ss;
for (auto it = b; it != e; it++) o << (it == b ? "" : ", ") << *it;
return... | 2 |
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long n1, long long n2) {
if (!n1) return n2;
if (!n2) return n1;
if (n1 % n2 == 0) return n2;
return gcd(n2, n1 % n2);
}
long long powmod(long long base, long long exponent) {
base %= 1000000007;
long long ans = 1;
while (exponent) {
if ... | 7 |
#include <bits/stdc++.h>
using namespace std;
const int inf = 2000000000;
int a[25][25], pow2[25], b[25], dp[(1 << 20) + 10], dp2[(1 << 20) + 10];
char s[25][25];
int main() {
int n, m;
scanf("%d%d", &n, &m);
for (int i = 0; i < n; i++) scanf("%s", s[i] + 1);
for (int i = 0; i < n; i++)
for (int j = 1; j <=... | 8 |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
if (n == 1) {
cout << "! 1 1" << endl;
continue;
}
vector<int> v1, v2;
for (int i = 1; i + 1 <= n; i += 2) {
cout << "? ... | 5 |
#include <bits/stdc++.h>
using namespace std;
int ans = 0;
int n;
int cnt = 26;
bool cant[26];
int main() {
cin >> n;
for (int i = 0; i + 1 < n; i++) {
char f;
cin >> f;
string s;
cin >> s;
if (f == '.') {
for (char j : s) {
cnt += cant[j - 'a'];
cant[j - 'a'] = true;
... | 4 |
#include <bits/stdc++.h>
using namespace std;
int n, k;
vector<vector<pair<int, int> > > adj(100005);
bool visited[100005];
deque<int> nodes;
long long ans1 = 0;
long long ans = 1;
int x = 1;
long long mod = 1000000007;
void dfs(int nd) {
visited[nd] = true;
for (int i = 0; i < adj[nd].size(); i++) {
if (visite... | 3 |
#include <bits/stdc++.h>
using namespace std;
inline void read(void) {}
long long int n, a, b;
long long int data[100003];
vector<pair<long long int, long long int> > v;
inline void solve(void) {
cin >> n >> a >> b;
for (int i = 0; i < n; i++) scanf("%lld", &data[i]);
for (int i = 0; i < n; i++) {
printf("%ll... | 3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n, m;
cin >> n >> m;
int v[n + 1][m + 1];
int nega = 0;
int mini = INT_MAX;
int ii, ij;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
int x;
cin >> x;
... | 1 |
#include <bits/stdc++.h>
using namespace std;
int n, m;
const int mod = 1e9 + 7;
char str[550][550];
int dp[2][550][550];
bool check(int x1, int y1, int x2, int y2) {
if (x1 >= 0 && x1 < n && y1 >= 0 && y1 < m && x2 >= 0 && x2 < n && y2 >= 0 &&
y2 < m && str[x1][y1] == str[x2][y2])
return true;
return fal... | 7 |
#include <bits/stdc++.h>
using namespace std;
const int MLG = 31;
int f[MLG] = {-1, 1, 2, 1, 4, 3, 2, 1, 5, 6, 2, 1, 8, 7, 5, 9,
8, 7, 3, 4, 7, 4, 2, 1, 10, 9, 3, 6, 11, 12, 12};
int cnt[MLG], n;
set<int> s;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> n;
for (int i = 2; 1... | 7 |
#include <bits/stdc++.h>
using namespace std;
const int Mod = 1000000007;
int add(int first, int second) {
first += second;
if (first >= Mod) return first - Mod;
return first;
}
int mul(int first, int second) {
return (int)((long long)first * second % Mod);
}
int pot(int first, int second) {
int r = 1;
whil... | 9 |
#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e5 + 123;
const long long INF = (long long)1e18 + 123;
const int inf = (int)1e9 + 123;
int n;
char c[10 * N];
int d[10 * N];
bool u[10 * N];
int s;
int main() {
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> c[i];
}
for (int i = 1; i <= n; i... | 1 |
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
vector<int> v[N];
vector<pair<int, int> > qs[N];
int mul[N], fen[N], ans[N];
void add(int x) {
for (; x < N; x += x & -x) fen[x]++;
}
int get(int x) {
int ret = 0;
for (; x; x -= x & -x) ret += fen[x];
return ret;
}
int main() {
ios_base::s... | 7 |
#include <bits/stdc++.h>
using namespace std;
struct big_integer {
static const int base = 1000;
static const int width = 3;
vector<int> v;
bool is_negative;
big_integer(long long num = 0) {
*this = num;
is_negative = false;
}
big_integer operator=(long long val) {
v.clear();
if (val < 0) ... | 4 |
#include <bits/stdc++.h>
using namespace std;
long long n1, n2, n3, day, month, year, m[105];
bool ok;
string s;
bool check(long long da, long long mont, long long yea) {
if (yea % 4 == 0)
m[2] = 29;
else
m[2] = 28;
if (mont < 13 && da <= m[mont] &&
(year - yea > 18 || year - yea == 18 && mont < mon... | 4 |
#include <bits/stdc++.h>
using namespace std;
long long modpow(long long pot) {
if (pot == 0) return 1;
if (pot == 1) return 2;
if (pot & 1) return 2 * modpow(pot - 1) % 1000000007;
long long k = modpow(pot / 2) % 1000000007;
return (k * k) % 1000000007;
}
int main() {
long long n;
cin >> n;
if (n == 0)... | 2 |
#include <bits/stdc++.h>
using namespace std;
const int MAX_BUF_SIZE = 16384;
char BUFOR[MAX_BUF_SIZE];
int BUF_SIZE, BUF_POS;
char ZZZ;
const int MXN = 1000010;
const int C = 262144;
const int INF = 1000000001;
char str[MXN];
int n;
void test() {
scanf("%s", str + 1);
n = strlen(str + 1);
int sum1 = 0, sum2 = 0;... | 4 |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
int tt;
cin >> tt;
while (tt--) {
int a, b, c, p;
cin >> a >> b >> c;
cout << max(a, max(b, c)) << endl;
}
}
| 0 |
#include <bits/stdc++.h>
using namespace std;
const int root = 0;
int idxN;
struct NODE {
int son[2];
int cnt;
void init() {
memset(son, -1, sizeof son);
cnt = 0;
}
} node[6000005];
int a[33];
void insert(int x, int f) {
for (int i = 0; i <= 30; ++i) a[i] = (x >> (30 - i)) & 1;
int i = 0, now = root... | 5 |
#include <bits/stdc++.h>
using namespace std;
int n;
int Sum(int x) {
int res;
res = 0;
while (x) {
res += x % 10;
x /= 10;
}
return res;
}
int Root(int x) {
if (x <= 9) return Sum(x);
return Root(Sum(x));
}
long long ans;
int q[20];
int p[1000010];
int pq;
bool pc[1000010];
int main() {
int k;
... | 6 |
#include <bits/stdc++.h>
int INF = 1e6;
using namespace std;
int main() {
int n, a, k;
cin >> n >> a;
if (a % 2 != 0) a = n - a + 1;
k = (n - a) / 2 + 1;
cout << k;
return 0;
}
| 1 |
#include <bits/stdc++.h>
using namespace std;
int read() {
int x = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-') f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
x = x * 10 + ch - '0';
ch = getchar();
}
return x * f;
}
struct vec {
int x[6];
int... | 4 |
#include <bits/stdc++.h>
const int maxn = 2002;
const long long inf = 1e18;
int n, m, s, t, type;
template <typename t1, typename t2>
inline std::ostream& operator<<(std::ostream& cout,
const std::pair<t1, t2>& pr) {
return cout << '(' << pr.first << ',' << pr.second << ')';
}
struct T... | 10 |
#include <bits/stdc++.h>
using namespace std;
inline int Read() {
char c = getchar();
int num = 0, f = 1;
while ('0' > c || c > '9') {
if (c == '-') f = -1;
c = getchar();
}
while ('0' <= c && c <= '9') num = num * 10 + c - '0', c = getchar();
return (num * f);
}
int n, m, a[200010];
struct Th {
i... | 10 |
#include <bits/stdc++.h>
using namespace std;
int a[(1 << 22)];
int order[(1 << 22)];
int ans[(1 << 22)];
int exam[(1 << 22)];
int exam2[(1 << 22)];
int n;
int main() {
cin >> n;
for (int i = 0; i < n; i++) {
int a2;
scanf("%d", &a2);
a[a2] = 1;
order[i] = a2;
}
for (int i = 0; i < (1 << 22); i+... | 7 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
long long ans = 0;
for (int i = (0); i < (n); ++i) {
long long t, T, x, cost;
cin >> t >> T >> x >> cost;
if (t >= T) {
ans += cost + m * x;
continue;
}
long long aux1 = cost;
if (m > (T - t))... | 5 |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000 + 5;
const int mod = 1e9 + 7;
long long dp[maxn][maxn];
int k, pa, pb;
int fb(int a, int n) {
if (n == 0) return 1;
int u = fb(a, n / 2);
int res = 1LL * u * u % mod;
if (n & 1)
return 1LL * res * a % mod;
else
return res;
}
int inv(i... | 7 |
#include <bits/stdc++.h>
using namespace std;
int main() {
double m, r;
double t = sqrt(2);
double ret = 0;
int i;
cin >> m >> r;
for (i = 0; i < m; i++) {
ret += 2 * r;
if (i + 1 < m) {
ret += 2 * r;
ret += r * t;
}
if (i + 2 < m) {
ret += r * (m - i - 1) * (m - i - 2);
... | 5 |
#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');
... | 3 |
#include <bits/stdc++.h>
using namespace std;
void setIO(string name = "") {
ios_base::sync_with_stdio(0);
cin.tie(0);
if (name.length()) {
freopen((name + ".in").c_str(), "r", stdin);
freopen((name + ".out").c_str(), "w", stdout);
}
}
int n;
int A[200001];
int main() {
setIO("");
cin >> n;
for (i... | 4 |
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
for (; b; a %= b, swap(a, b))
;
return a;
}
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
int main(void) {
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
long long n, m;
cin >> n >> m;
vector<long long> ... | 5 |
#include <bits/stdc++.h>
using namespace std;
vector<array<int, 2>> ans;
void solve(vector<int> &a) {
if (a.size() <= 1) return;
vector<int> id[2];
for (int i = 0; i < a.size(); i++) id[i & 1].push_back(a[i]);
solve(id[0]);
solve(id[1]);
for (int i = 0; i < int(a.size()) / 2; i++)
ans.push_back({id[0][i... | 7 |
#include <bits/stdc++.h>
using namespace std;
int flip(int x, int a, int b) {
if (a <= x && x <= b) return a + b - x;
return x;
}
int n;
int x[31];
double p[31][31];
double nextP[31][31];
int MAIN() {
int times;
cin >> n >> times;
for (int i = 1; i <= n; i++) cin >> x[i];
memset(p, 0, sizeof(p));
for (int... | 8 |
#include <bits/stdc++.h>
using namespace std;
const int U = 80;
const int L = 20000;
long long n;
int m, a[111];
int F[U][L];
int f0(int n, int i) {
if (n == 0 || i < 0) return n;
int &res = F[i][n];
if (res < 0) {
res = n;
for (; i >= 0; --i) res -= f0(n / a[i], i - 1);
}
return res;
}
long long f(lo... | 9 |
#include <bits/stdc++.h>
using namespace std;
inline double sqr(double x) { return x * x; }
#pragma comment(linker, "/STACK:16777216")
int k;
string lst(string s, int n) {
int i = s.size(), ctr = 0;
string r, v = "aeiou";
while (i--) {
r = s[i] + r;
if (v.find(s[i]) != -1) ++ctr;
if (ctr == k) return ... | 4 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.