# 第十四届蓝桥杯三月真题刷题训练——第 16 天 （3.19）

Yapink 2023-03-19 20:42:14

``````#include <iostream>

using namespace std;

int main()
{
int n;
cin >> n;
cout << (char)(n + 64) << endl;
return 0;
}``````
``````#include <iostream>

using namespace std;

int main()
{
int n;
cin >> n;
printf("%c\n", n - 1 + 'A');
return 0;
}``````

``````#include <iostream>

using namespace std;

// char str[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j','k',
//     'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

int cnt[26];

int main()
{
string s;
cin >> s;
for (int i = 0; i < s.size(); i ++ )
cnt[s[i] - 'a'] ++ ;

int p = 0;
for (int i = 1; i <= 26; i ++ )
if (cnt[i] > cnt[p]) p = i;

cout << (char)(p + 'a') << endl << cnt[p] << endl;

return 0;
}``````

``````#include <iostream>

using namespace std;

typedef long long LL;

const int N = 100010;

int n, m, q;
int p[N];
LL d[N];

int find(int x)
{
if (p[x] != x)
{
int t = find(p[x]);
d[x] += d[p[x]];
p[x] = t;
}
return p[x];
}

int main()
{
scanf("%d%d%d", &n, &m, &q);
for (int i = 1; i <= n; i ++ ) p[i] = i;

while (m -- )
{
int l, r;
LL s;
cin >> l >> r >> s;
int pa = find(l - 1), pb = find(r);
if (pa != pb)
{
p[pa] = pb;
d[pa] = d[r] - d[l - 1] - s;
}
}

while (q -- )
{
int l, r;
cin >> l >> r;
int pa = find(l - 1), pb = find(r);
if (pa != pb) puts("UNKNOWN");
else cout << d[r] - d[l - 1] << endl;
}
return 0;
}``````

...全文
6 回复 打赏 收藏 举报

4.0w+

2023-03-19 20:42

刷题！