2020/11/14裂开了

<>第十一届蓝桥杯国赛C/C++B组总结

<>试题 A: 美丽的 2

【问题描述】

563

<>试题 B: 扩散

【问题描述】

20312088

#include<iostream> #include<cstdio> #include<cstdlib> #include<string> #include
<cstring> #include<stack> #include<set> #include<map> #include<queue> #include
<algorithm> #include<unordered_set> #define ll long long #define pii
pair<int,int> #define pll pair<ll,ll> #define mp make_pair #define pb push_back
#define G 6.67430*1e-11 #define rd read() #define pi 3.1415926535 using
namespace std; const ll mod = 998244353; inline ll read() { ll 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 << 1) + (x << 3) + (ch ^ 48
); ch = getchar(); } return x * f; } ll gcd(ll a, ll b) { return !b ? a : gcd(b,
a% b); } queue < pair<pair<int, int>, int > >q;
//记录下每一个<x,y>坐标是第t秒变黑的x,y,t分别对应前面的三个维度 map<pii, int> vis; int nexti[4][2] = { {1
,0},{0,1},{-1,0},{0,-1} }; int main() { q.push(mp(mp(0, 0), 0)); q.push(mp(mp(
2020, 11), 0)); q.push(mp(mp(11, 14), 0)); q.push(mp(mp(2000, 2000), 0)); vis[mp
(0, 0)] = 1; vis[mp(2020, 11)] = 1; vis[mp(11, 14)] = 1; vis[mp(2000, 2000)] = 1
; ll ans = 4; int bf = -1; while (1) { auto p = q.front().first; int time = q.
front().second; /*if (bf != time) { bf = time; cout << time << endl; }*/ if (
time== 2020)break;//这个是2020分钟生成的 for (int i = 0; i < 4; i++) { int nx = p.first
+ nexti[i][0]; int ny = p.second + nexti[i][1]; if (!vis[mp(nx,ny)]) { vis[mp(nx
, ny)] = 1; ans++; q.push(mp(mp(nx, ny), time + 1)); } } q.pop(); } cout << ans;
}
(要跑挺久，我直接附上截图了）

<>试题 C: 阶乘约数

【问题描述】

39001250856960000

#include<iostream> #include<cstdio> #include<cstdlib> #include<string> #include
<cstring> #include<stack> #include<set> #include<map> #include<queue> #include
<algorithm> #include<unordered_set> #define ll long long #define pii
pair<int,int> #define pll pair<ll,ll> #define mp make_pair #define pb push_back
#define G 6.67430*1e-11 #define rd read() #define pi 3.1415926535 using
namespace std; const ll mod = 998244353; inline ll read() { ll 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 << 1) + (x << 3) + (ch ^ 48
); ch = getchar(); } return x * f; } ll gcd(ll a, ll b) { return !b ? a : gcd(b,
a% b); } int flag[105]; int main() { int i; for (int i = 2; i <= 100; i++) {
int tmp = i; for (int j = 2; j <= tmp; j++) { while (tmp % j == 0) { tmp /= j;
flag[j]++; } } } ll ans = 1; for (int i = 1; i <= 100; i++) { ans *= flag[i] + 1
; } cout << ans; }
<>试题 D: 本质上升序列

【问题描述】

ao。小蓝认为他们并没有本质不同。

l、a、n、q、i、o、ln、an、lq、aq、nq、ai、lo、ao、no、io、lnq、anq、lno、ano、aio。

inc.txt,内容与下面的文本相同)

3616159

#include<iostream> #include<cstdio> #include<cstdlib> #include<string> #include
<cstring> #include<stack> #include<set> #include<map> #include<queue> #include
<algorithm> #include<unordered_set> #define ll long long #define pii
pair<int,int> #define pll pair<ll,ll> #define mp make_pair #define pb push_back
#define G 6.67430*1e-11 #define rd read() #define pi 3.1415926535 using
namespace std; const ll mod = 998244353; inline ll read() { ll 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 << 1) + (x << 3) + (ch ^ 48
); ch = getchar(); } return x * f; } ll gcd(ll a, ll b) { return !b ? a : gcd(b,
a% b); } map<string, int> vis; int main() { queue<pair<string, int>> q; string
s; cin >> s; int i; ll ans = 0; for (i = 0; i < s.size(); i++) { string tmp = ""
; tmp += s[i]; if (!vis[tmp]) { vis[tmp] = 1; q.push(mp(tmp, i)); ans++; } }
while (q.size()) { string t = q.front().first; int pos = q.front().second; q.pop
(); for (int i = pos + 1; i < s.size(); i++) { if (s[i] > s[pos] && !vis[t + s[i
]]) { vis[t + s[i]] = 1; q.push(mp(t + s[i], i)); ans++; } } } cout << ans; }

<>试题 E: 玩具蛇

【问题描述】

552

#include<iostream> #include<cstdio> #include<cstdlib> #include<string> #include
<cstring> #include<stack> #include<set> #include<map> #include<queue> #include
<algorithm> #include<unordered_set> #define ll long long #define pii
pair<int,int> #define pll pair<ll,ll> #define mp make_pair #define pb push_back
#define G 6.67430*1e-11 #define rd read() #define pi 3.1415926535 using
namespace std; const ll mod = 998244353; inline ll read() { ll 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 << 1) + (x << 3) + (ch ^ 48
); ch = getchar(); } return x * f; } ll gcd(ll a, ll b) { return !b ? a : gcd(b,
a% b); } int vis[5][5]; int nexti[4][2] = { {0,1},{1,0},{0,-1},{-1,0} }; ll ans
= 0; void dfs(int x, int y,int count) { if (x >= 4 || x < 0 || y >= 4 || y < 0)
return; if (count == 16) { ans++; } for (int i = 0; i < 4; i++) { int nx = x +
nexti[i][0]; int ny = y + nexti[i][1]; if (!vis[nx][ny]) { vis[nx][ny] = 1; dfs(
nx, ny, count + 1); vis[nx][ny] = 0; } } } int main() { int i; for (i = 0; i < 4
; i++) { for (int j = 0; j < 4; j++) { vis[i][j] = 1; dfs(i, j, 1); vis[i][j] =
0; } } cout << ans; }

<>试题 H: 答疑

【问题描述】

* 首先进入办公室，编号为 i 的同学需要 si 毫秒的时间。
* 然后同学问问题老师解答，编号为 i 的同学需要 ai 毫秒的时间。
* 答疑完成后，同学很高兴，会在课程群里面发一条消息，需要的时间可

* 最后同学收拾东西离开办公室，需要 ei 毫秒的时间。一般需要 10 秒、
20 秒或 30 秒，即 ei 取值为 10000，20000 或 30000。

Toolsou
API参考文档