日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > c/c++ >内容正文

c/c++

第十届蓝桥杯大赛软件赛省赛 C/C++ 大学B组

發布時間:2025/3/19 c/c++ 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 第十届蓝桥杯大赛软件赛省赛 C/C++ 大学B组 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

試題A :組隊


490

試題B :年號字串

// BYQ #include <iostream> #include <algorithm> using namespace std;int main() {string res = "";int n = 2019;while (n){n -- ;res += (char)('A' + n % 26);n /= 26;}reverse(res.begin(), res.end());cout << res; }

試題C :數列求值

// 4659 #include <iostream> #include <algorithm> using namespace std;const int N = 3e7;int f[N];int main() {f[1] = 1;f[2] = 1;f[3] = 1;for (int i = 4; i <= 20190324; i ++ )f[i] = (f[i - 3] + f[i - 2] + f[i - 1]) % 10000;cout << f[20190324]; }

試題D :數的分解

// 40785 #include <iostream> #include <algorithm> using namespace std;bool check(int n) {while (n){int now = n % 10;if (now == 2 || now == 4) return true;n /= 10;}return false; }int main() {int res = 0;for (int i = 1; i < 2019; i ++ ){if (check(i)) continue;for (int j = i + 1; j < 2019; j ++ ){if (check(j)) continue;for (int k = j + 1; k < 2019; k ++ ){if (check(k)) continue;if (i + j + k == 2019) res ++ ;}}}cout << res; }

試題E :迷宮

#include <iostream> #include <queue> using namespace std;const int N = 55;struct Point {int x, y;string road; };int n = 30, m = 50; char g[N][N]; bool vis[N][N]; int dx[] = {1, 0, 0, -1}, dy[] = {0, -1, 1, 0}; char op[] = {'D', 'L', 'R', 'U'};void bfs() {queue<Point> que;vis[0][0] = true;que.push({0, 0, ""});while (que.size()){auto t = que.front(); que.pop();if (t.x == n - 1 && t.y == m - 1){cout << t.road;return ;}for (int i = 0; i < 4; i ++ ){int ax = t.x + dx[i], ay = t.y + dy[i];if (ax < 0 || ax >= n || ay < 0 || ay >= m) continue;if (!vis[ax][ay] && g[ax][ay] == '0'){Point pt = {ax, ay, t.road + op[i]};vis[ax][ay] = true;que.push(pt);}}} }int main() {for (int i = 0; i < n; i ++ ){scanf("%s", g[i]);getchar();}bfs(); }

試題F :特別數的和

#include <iostream> using namespace std;bool check(int x) {while (x){int now = x % 10;if (now == 2 || now == 0 || now == 1 || now == 9) return true;x /= 10;}return false; }int main() {int n; cin >> n;int res = 0;for (int i = 1; i <= n; i ++ ){if (check(i)) res += i;}cout << res; }

試題G :完全二叉樹的權值

#include <iostream> #include <vector> using namespace std;vector<int> ve[20]; int ww[20]; int level;int calc(int b) {int res = 1;for (int i = 1; i <= b + 1; i ++ ) res *= 2;return res - 1; }int main() {int n; cin >> n;int power = calc(0);for (int i = 1, w; i <= n && scanf("%d", &w); i ++ ){if (i > power){level ++ ;power = calc(level);}ve[level].push_back(w);}int mx = 0, ans;for (int i = 0; i <= level; i ++ ){for (auto j : ve[i])ww[i] += j;if (ww[i] > mx){mx = ww[i];ans = i;}}cout << ans + 1; }

試題H :等差數列

#include <iostream> #include <algorithm> using namespace std;const int N = 1e5 + 10;int n, a[N];int main() {scanf("%d", &n);for (int i = 0; i < n && scanf("%d", &a[i]); i ++ );sort(a, a + n);int d = 1e9 + 10;for (int i = 1; i < n; i ++ )d = min(d, a[i] - a[i - 1]);if (d == 0){cout << n;return 0;}printf("%d", (a[n - 1] - a[0]) / d + 1); }

試題I :后綴表達式

#include <iostream> #include <algorithm> #include <cmath> using namespace std;typedef long long ll;const int N = 2e5 + 10;int n, m; int a[N];int main() {scanf("%d%d", &n, &m);for (int i = 0; i < n + m + 1 && scanf("%d", &a[i]); i ++ );sort(a, a + n + m + 1);ll res = 0;if (!m){for (int i = 0; i < n + m + 1; i ++ ) res += a[i];}else{res = a[n + m] - a[0];for (int i = 1; i < n + m; i ++ )res += abs(a[i]);}cout << res; }

試題J :靈能傳輸


與50位技術專家面對面20年技術見證,附贈技術全景圖

總結

以上是生活随笔為你收集整理的第十届蓝桥杯大赛软件赛省赛 C/C++ 大学B组的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。