# 预备知识：

## 12.五大中值定理（罗尔，拉格朗日，柯西，泰勒，积分）

12天前
#include <iostream>

using namespace std;

const int N = 10;

bool st[N];
int n;
int ans[N];

void dfs(int t)
{
if(t == n)
{
for (int i = 0; i < n; i ++) cout << ans[i] << ' ';
cout << endl;
return;
}

for (int i = 1; i <= n; i ++)
if (!st[i])
{
ans[t] = i, st[i] = true;
dfs(t + 1);
st[i] = false;
}
}

int main()
{
cin >> n;
dfs(0);
return 0;
}

15天前
#include <iostream>

using namespace std;

typedef unsigned long long ULL;

const int N = 1e5 + 10, P = 131;

int n, m;
char str[N];
ULL h[N], p[N]; //p存储P的各个次方

ULL get(int l, int r)
{
return h[r] - h[l - 1] * p[r - l + 1];
}

int main()
{
cin >> n >> m;
scanf("%s", str + 1);

p[0] = 1;
for (int i = 1; i <= n; i ++)
p[i] = p[i - 1] * P, h[i] = h[i - 1] * P + str[i];

while(m --)
{
int l1, r1, l2, r2;
cin >> l1 >> r1 >> l2 >> r2;
if(get(l1, r1) == get(l2, r2)) puts("Yes");
else puts("No");
}
return 0;
}

15天前

#include <iostream>
#include <cstring>

using namespace std;

const int N = 3e5 + 7, null = 0x3f3f3f3f;

int h[N];

int find (int x)
{
int k = (x % N + N) % N;
while(h[k] != null && h[k] != x)
{
k ++;
if(k == N) k = 0;
}
return k;
}

int main ()
{
memset(h, 0x3f, sizeof h);
int k;
cin >> k;
while(k --)
{
int v;
char op[10];
cin >> op >> v;
if(!strcmp(op, "I")) h[find(v)] = v;
else
{

if(h[find(v)] == null) puts("No");
else puts("Yes");
}
}
return 0;
}

#include <iostream>
#include <cstring>

using namespace std;

const int N = 1e5 + 3;

int h[N], ne[N], e[N], idx;

void insert(int x)
{
int p = (x % N + N) % N;
e[idx] = x;
ne[idx] = h[p];
h[p] = idx ++;
}

bool find(int x)
{
int p = (x % N + N) % N;
for(int i = h[p]; ~i; i = ne[i])
if(e[i] == x) return true;
return false;
}

int main()
{
memset(h, -1, sizeof h);

int n;
cin >> n;

while(n --)
{
char op[10];
int v;
cin >> op >> v;

if(!strcmp("I", op)) insert(v);
else
{
if(find(v)) puts("Yes");
else puts("No");
}
}
return 0;
}

28天前

29天前
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>

using namespace std;

const int N = 1e6;

int n;
double p[N], res[N];
double sum, tmp, Avg, ans;

int main ()
{
cin >> n >> sum;
for (int i = 0; i < n; i ++) cin >> p[i];
tmp = sum;
Avg = sum / n;
sort (p, p + n);

for (int i = 0; i < n; i ++)
{

if (p[i] < Avg)
res[i] = p[i], sum -= p[i],
Avg = sum / (n - i - 1);
else res[i] = Avg, sum -= Avg;
}

Avg = tmp / n;
for (int i = 0; i < n; i ++) ans += (res[i] - Avg) * (res[i] - Avg);
ans = sqrt (ans / n);

printf ("%.4lf", ans);
return 0;
}

29天前
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

const int N = 1010;

int n, d;
struct Segment
{
double l, r;
bool operator< (const Segment& t) const
{
return r < t.r;
}
}seg[N];

int main()
{
scanf("%d%d", &n, &d);

bool failed = false;
for (int i = 0; i < n; i ++ )
{
int x, y;
scanf("%d%d", &x, &y);
if (y > d) failed = true;
else
{
double len = sqrt(d * d - y * y);
seg[i].l = x - len, seg[i].r = x + len;
}
}

if (failed)
{
puts("-1");
}
else
{
sort(seg, seg + n);

int cnt = 0;
double last = -1e20;
for (int i = 0; i < n; i ++ )
if (last < seg[i].l)
{
cnt ++ ;
last = seg[i].r;
}

printf("%d\n", cnt);
}

return 0;
}

30天前
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 1e5 + 10;

int n;
int s[N];

int main ()
{
cin >> n;
for (int i = 0; i < n; i ++) cin >> s[i];
sort (s, s + n);

int st = s[(n - 1) / 2], ans = 0;
for (int i = 0; i < n; i ++) ans += abs (s[i] - st);
cout << ans << endl;
return 0;
}

30天前
#include <iostream>

using namespace std;

const int N = 1e5 + 10;

int n, ans;;
int s[N];

int main ()
{
cin >> n;
for (int i = 0; i < n; i ++) cin >> s[i];

for (int i = 0; i + 1 < n; i ++)
if (s[i] < s[i + 1]) ans += s[i + 1] - s[i];

cout << ans;
return 0;
}