Wellcome to my csdn, Thank you !
This is CoderForces 479 div3.
#include<cstdio>
#include<iostream>
#include<cstring>
#include<math.h>
#include<map>
#include<algorithm>
#include<string>
#include<set>
#include<vector>
typedef long long LL;
const LL N = 200000 + 5;
#define INF 10000000
#define min(a , b) ((a) < (b) ? (a) : (b))
#define lowbit(x) x&-x
using namespace std;
typedef long long ll;
const int maxn = int(2e5) + 7;
ll k[maxn], sum[maxn], dmg;
LL a[maxn], ans;
vector<int>v[N];
int main() {
int n, k;
set<int>s;
set<int>::iterator it;
while (cin >> n >> k) {
while (k--) {
if (n == 0)break;
if (n % 10)n--;
else n /= 10;
}
cout << n << endl;
}
}
#include<cstdio>
#include<iostream>
#include<cstring>
#include<math.h>
#include<map>
#include<algorithm>
#include<string>
#include<set>
#include<vector>
typedef long long LL;
const LL N = 200000 + 5;
#define INF 10000000
#define min(a , b) ((a) < (b) ? (a) : (b))
#define lowbit(x) x&-x
using namespace std;
typedef long long ll;
const int maxn = int(2e5) + 7;
ll k[maxn], sum[maxn], dmg;
LL a[maxn], ans;
vector<int>v[N];
int main() {
int n;
cin >> n;
char st[101];
cin >> st;
map<string, int>mp;
map<int, string>ans;
set<string>s;
int a[101] = { 0 };
int k = 0;
int tt = 0;
for (int i = 0; i < strlen(st) - 1; i++) {
char t[3];
t[0] = st[i];
t[1] = st[i + 1];
t[2] = '\0';
s.insert(t);
if (tt == s.size()) {
a[mp[t]]++;
}
else
{
mp[t] = k;
ans[k++] = t;
a[mp[t]]++;
tt = s.size();
}
}
int max = 0;
for (int i = 1; i < k; i++) {
if (a[max] < a[i])max = i;
}
cout << ans[max] << endl;
s.clear();
}
#include<cstdio>
#include<iostream>
#include<cstring>
#include<math.h>
#include<map>
#include<algorithm>
#include<string>
#include<set>
#include<vector>
typedef long long LL;
const LL N = 200000 + 5;
#define INF 10000000
#define min(a , b) ((a) < (b) ? (a) : (b))
#define lowbit(x) x&-x
using namespace std;
typedef long long ll;
const int maxn = int(2e5) + 7;
ll k[maxn], sum[maxn], dmg;
LL a[maxn], ans;
vector<int>v[N];
int main() {
int n, k;
while (cin >> n >> k) {
for (int i = 0; i < n; i++) {
scanf("%lld", &a[i]);
}
sort(a, a + n);
if (k == 0) {
if (a[0] == 1)
cout << "-1\n";
else cout << "1\n";
continue;
}
if (a[k] == a[k - 1])cout << "-1\n";
else cout << a[k - 1] << endl;
}
}
#include<cstdio>
#include<iostream>
#include<cstring>
#include<math.h>
#include<map>
#include<algorithm>
#include<string>
#include<set>
#include<vector>
typedef long long LL;
const LL N = 200000 + 5;
#define INF 10000000
#define min(a , b) ((a) < (b) ? (a) : (b))
#define lowbit(x) x&-x
using namespace std;
typedef long long ll;
const int maxn = int(2e5) + 7;
ll k[maxn], sum[maxn], dmg;
LL a[maxn], ans;
vector<int>v[N];
int main() {
int n;
while (cin >> n) {
int tt[101] = { 0 };
LL next[101] = { 0 };
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
if (i == j)continue;
if (a[i] * 2 == a[j] || a[i] == a[j] * 3) {
next[i] = j;
tt[j] = 1;
}
}
}
for (int i = 1; i <= n; i++) {
if (!tt[i]) {
while (i) {
cout << a[i] << " ";
i = next[i];
}
return 0;
}
}
cout << endl;
}
}
#include<cstdio>
#include<iostream>
#include<cstring>
#include<math.h>
#include<map>
#include<algorithm>
#include<string>
#include<set>
#include<vector>
typedef long long LL;
const LL N = 200000 + 5;
#define INF 10000000
#define min(a , b) ((a) < (b) ? (a) : (b))
#define lowbit(x) x&-x
using namespace std;
typedef long long ll;
const int maxn = int(2e5) + 7;
ll k[maxn], sum[maxn], dmg;
LL a[maxn], ans;
vector<int>v[N];
void dfs(int t) {
a[t] = 1;
if (v[t].size() != 2)ans = 0;
for (int i = 0; i < v[t].size(); i++) {
if (!a[v[t][i]])dfs(v[t][i]);
}
}
int main() {
ios::sync_with_stdio(false);
int n, m;
cin >> n >> m;
memset(a, 0, sizeof(a));
int s, e;
for (int i = 0; i < m; i++) {
cin >> s >> e;
v[s].push_back(e);
v[e].push_back(s);
}
int t = 0;
for (int i = 0; i < n; i++) {
if (!a[i]) {
ans = 1;
dfs(i);
if (ans)t++;
}
}
cout << t << endl;
}