【每日一題 | 2025】2.24 ~ 3.2

在這里插入圖片描述

個人主頁:Guiat
歸屬專欄:每日一題

在這里插入圖片描述

文章目錄

  • 1. 【2.24】P10424 [藍橋杯 2024 省 B] 好數
  • 2. 【2.25】P8665 [藍橋杯 2018 省 A] 航班時間
  • 3. 【2.26】P10905 [藍橋杯 2024 省 C] 回文字符串
  • 4. 【2.27】P10425 [藍橋杯 2024 省 B] R 格式
  • 5. 【2.28】P10426 [藍橋杯 2024 省 B] 寶石組合
  • 6. 【3.1】P10912 [藍橋杯 2024 國 B] 數星星
  • 7. 【3.2】P10914 [藍橋杯 2024 國 B] 跳石頭

正文

1. 【2.24】P10424 [藍橋杯 2024 省 B] 好數

題目鏈接:https://www.luogu.com.cn/problem/P10424

【AC_Code】

#include <iostream>
#define IOS ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);using namespace std;int N, cnt;bool check(int n)
{int number = 1;while (n > 0){if (number % 2 == 1) { if ((n % 10) % 2 == 0) return false; }else if ((n % 10) % 2 != 0) return false;n /= 10; number ++;}return true;
}int main()
{IOS; cin >> N;for (int i = 1; i <= N; i ++) if (check(i)) cnt ++;cout << cnt << '\n';return 0;
}

2. 【2.25】P8665 [藍橋杯 2018 省 A] 航班時間

題目鏈接:https://www.luogu.com.cn/problem/P8665

【AC_Code】

#include <iostream>
#include <iomanip>
#define IOS ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);using namespace std;int solve()
{int h1, m1, s1, h2, m2, s2, d = 0; char c1, c2, c3, c4, c5, c6;cin >> h1 >> c1 >> m1 >> c2 >> s1 >> h2 >> c3 >> m2 >> c4 >> s2;if (cin.peek() == ' ') cin >> c5 >> d >> c6;return (86400 * d + 3600 * h2 + 60 * m2 + s2) - (3600 * h1 + 60 * m1 + s1);
}int main()
{IOS; int T; cin >> T;while (T --){int ans = (solve() + solve()) >> 1;cout << setw(2) << setfill('0') << ans / 3600 << ':'<< setw(2) << setfill('0') << (ans % 3600) / 60 << ':'<< setw(2) << setfill('0') << ans % 60 << '\n';}return 0;
}

3. 【2.26】P10905 [藍橋杯 2024 省 C] 回文字符串

題目鏈接:https://www.luogu.com.cn/problem/P10905

【AC_Code】

#include <iostream>
#include <string>
#define IOS ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);using namespace std;void solve()
{string s; cin >> s; int l = 0, r = s.length() - 1;while (s[l] == 'l' || s[l] == 'q' || s[l] == 'b') l ++;while (s[r] == 'l' || s[r] == 'q' || s[r] == 'b') r --;bool flag = true;for (int i = l, j = 0; i <= (l + r) / 2; i ++, j ++) if (s[i] != s[r - j]) flag = false;if ( ! flag ) cout << "No\n";else if (l == 0) cout << "Yes\n";else if (r == s.length() - 1) cout << "No\n";else if (s.length() - r < l) cout << "No\n";else{l --; r ++;while (s[l] == s[r] && l >= 0 && r <= s.length()) l --, r ++;if (r == s.length() || l == -1) cout << "Yes\n";else cout << "No\n";}
}int main()
{IOS; int T; cin >> T; while (T--) solve();return 0;
}

4. 【2.27】P10425 [藍橋杯 2024 省 B] R 格式

題目鏈接:https://www.luogu.com.cn/problem/P10425

【AC_Code】

#include <iostream>
#include <algorithm>
#define IOS ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);using namespace std;const int N = 1e6;
int n, a[N], pos, len; string q;void solve()
{reverse(q.begin(), q.end());pos = q.find('.'); q.erase(pos, 1); len = q.size();for (int i = 0; i < len; i ++) a[i + 1] = q[i] - '0';for (int i = 1; i <= n; i ++){for (int i = 1; i <= len; i ++) a[i] *= 2;for (int i = 1; i <= len; i ++) a[i + 1] += a[i] / 10, a[i] %= 10;if (a[len + 1]) len ++;}if (a[pos] >= 5) a[pos + 1] ++;for (int i = pos + 1; i <= len; i ++) a[i + 1] += a[i] / 10, a[i] %= 10;if (a[len + 1]) len ++;for (int i = len; i > pos; i --) cout << a[i]; cout << '\n';
}int main()
{IOS; cin >> n >> q; solve();return 0;
}

5. 【2.28】P10426 [藍橋杯 2024 省 B] 寶石組合

題目鏈接:https://www.luogu.com.cn/problem/P10426

【AC_Code】

#include <iostream>
#include <vector>
#include <algorithm>
#define IOS ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);using namespace std;const int MAXN = 1e5 + 10; int n, h[MAXN]; vector<int> fac[MAXN];int gcd(int a, int b) { return __gcd(a, b); }void solve()
{cin >> n; for (int i = 1; i <= n; ++ i) cin >> h[i];sort(h + 1, h + 1 + n);for (int i = 1; i <= n; ++ i) for (int j = 1; j * j <= h[i]; ++j){if (h[i] % j == 0){fac[j].push_back(h[i]);if (h[i] / j != j) fac[h[i] / j].push_back(h[i]);}}for (int i = MAXN; i >= 1; -- i){if (fac[i].size() >= 3){int a = fac[i][0], b = fac[i][1], c = fac[i][2];if (gcd(gcd(a, b), c) == i) { cout << a << " " << b << " " << c << "\n"; return; }}}
}int main()
{IOS; solve();return 0;
}

6. 【3.1】P10912 [藍橋杯 2024 國 B] 數星星

題目鏈接:https://www.luogu.com.cn/problem/P10912

【AC_Code】

#include <iostream>
#include <vector>
#include <algorithm>
#define IOS ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);using namespace std;const int N = 1e5 + 10, mod = 1e9 + 7;
int n, a[N], b[N], c[N], f[N], l, r, ans;
vector<int> vec[N];int fun(int x, int y) { return 1ll * b[x] * f[y] % mod * f[x - y] % mod; }void DFS(int x, int y)
{for (auto n : vec[x]) if (n != y) DFS(n, x);if (static_cast<int> (vec[x].size()) + 1 >= 1){int p = min(r - 1, static_cast<int> (vec[x].size()));for (int i = l - 1; i <= p; i ++) ans = (ans + fun(vec[x].size(), i)) % mod;}
}void solve()
{cin >> n; b[0] = c[0] = 1; b[1] = 1; c[1] = 1; f[0] = 1; f[1] = 1;for (int i = 2; i <= n; i ++){b[i] = 1ll * b[i - 1] * i % mod;c[i] = 1ll * c[mod % i] * (mod - mod / i) % mod;f[i] = 1ll * f[i - 1] * c[i] % mod;}for (int i = 1; i < n; i ++){int x, y; cin >> x >> y;vec[x].push_back(y); vec[y].push_back(x);}cin >> l >> r;DFS(1, 0);cout << ans << '\n';
}int main()
{IOS; solve();return 0;
}

7. 【3.2】P10914 [藍橋杯 2024 國 B] 跳石頭

題目鏈接:https://www.luogu.com.cn/problem/P10914

【AC_Code】

#include <iostream>
#include <bitset>
#define IOS ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0); using namespace std;const int N = 4e4 + 10; int c[N], n, ans;
bitset<N> f[N];void solve()
{cin >> n;for (int i = 1; i <= n; i ++){cin >> c[i]; f[i][c[i]] = 1;}for (int i = n; i >= 1; i --){if (i + c[i] <= n) f[i] |= f[i + c[i]];if (2 * i <= n) f[i] |= f[2 * i];ans = max(ans, (int)f[i].count());}cout << ans << '\n';
}int main()
{IOS; solve();return 0;
}

結語
感謝您的閱讀!期待您的一鍵三連!歡迎指正!

在這里插入圖片描述

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/diannao/72274.shtml
繁體地址,請注明出處:http://hk.pswp.cn/diannao/72274.shtml
英文地址,請注明出處:http://en.pswp.cn/diannao/72274.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

【03】STM32F407 HAL 庫框架設計學習

【03】STM32F407 HAL 庫框架設計學習 摘要 本文旨在為初學者提供一個關于STM32F407微控制器HAL&#xff08;Hardware Abstraction Layer&#xff09;庫框架設計的詳細學習教程。通過本文&#xff0c;讀者將從零開始&#xff0c;逐步掌握STM32F407的基本知識、HAL庫的配置步驟…

跟著官方文檔學習UE C++ TArray容器系列 迭代 和 排序

一.首先測試下&#xff0c;官方案例 迭代器的方法&#xff0c;有點不常見。有點像個指針&#xff0c;迭代完還自帶break. oid AWXTArrayActor::WXLoopArray() {FString JoinedStr1;FString JoinedStr2;TArray<FString> StrArr { "Hello","Baby",&q…

C++中的“結界”機制:作用域與變量可見性探秘

一、編程世界的“結界”概念 源自佛學的結界概念&#xff0c;在C中體現為作用域機制。程序中的每個函數都會形成獨立的作用域屏障&#xff0c;如同魔法結界般保護內部變量&#xff0c;使其與外界的同名變量互不干擾。這種機制保證了代碼模塊的獨立性和安全性&#xff0c;但當存…

3-6 WPS JS宏 工作表移動復制實例-1(工作表的拆分操作)學習筆記

************************************************************************************************************** 點擊進入 -我要自學網-國內領先的專業視頻教程學習網站 *******************************************************************************************…

Qt 對象樹詳解:從原理到運用

1. 什么是對象樹&#xff1f; 對象樹是一種基于父子關系的對象管理機制。在 Qt 中&#xff0c;所有繼承自 QObject 的類都可以參與到對象樹中。 當一個對象被設置為另一個對象的父對象時&#xff0c;子對象會被添加到父對象的內部列表中&#xff0c;形成一種樹狀結構。 Qt 提…

使用hutool將json集合對象轉化為對象

集合之間相互轉化 //List轉Json&#xff0c;maps是List類型的參數 String json JSONUtil.toJsonStr(maps); System.out.println("這是json字符串: "json);//Json轉List JSONArray objects JSONUtil.parseArray(json); List<Map> maps1 JSONUtil.toList(objec…

Qt關于平滑滾動的使用QScroller及QScrollerProperties類說明

一、觸控時代的滾動工具&#xff1a;QScroller類設計介紹 1.1 從機械滾輪到數字慣性 在觸控設備普及前&#xff0c;滾動操作如同老式打字機的滾軸&#xff0c;只能通過鼠標滾輪或滾動條進行離散式控制。QScroller的出現如同給數字界面裝上了"慣性飛輪"&#xff0c;…

JavaAPI(網絡編程)

網絡通信協議 通信協議 ?所謂通信協議&#xff0c;是指通信雙方在進行數據交換時必須遵守的規則和約定。?這些規則確保了雙方能夠有效地進行通信&#xff0c;實現信息的交換和資源共享。通信協議定義了傳輸時的數據格式、控制信息以及傳輸順序和速度等&#xff0c;確保雙方…

Java---入門基礎篇(下)---方法與數組

前言 本篇文章主要講解有關方法與數組的知識點 ,是基礎篇的一部分 , 而在下一篇文章我會講解類和對象的知識點 入門基礎篇上的鏈接給大家放在下面啦 ! Java---入門基礎篇(上)-CSDN博客 感謝大家點贊&#x1f44d;&#x1f3fb;收藏?評論?&#x1f3fb; 歡迎各位大佬指點…

Python 爬蟲 – BeautifulSoup

Python 爬蟲&#xff08;Web Scraping&#xff09;是指通過編寫 Python 程序從互聯網上自動提取信息的過程。 爬蟲的基本流程通常包括發送 HTTP 請求獲取網頁內容、解析網頁并提取數據&#xff0c;然后存儲數據。 Python 的豐富生態使其成為開發爬蟲的熱門語言&#xff0c;特…

圖像分類項目1:基于卷積神經網絡的動物圖像分類

一、選題背景及動機 在現代社會中&#xff0c;圖像分類是計算機視覺領域的一個重要任務。動物圖像分類具有廣泛的應用&#xff0c;例如生態學研究、動物保護、農業監測等。通過對動物圖像進行自動分類&#xff0c;可以幫助人們更好地了解動物種類、數量和分布情況&#xff0c;…

物聯網 智慧園區井蓋管理辦法和功能介紹

在園區內實現 智慧井蓋 的定位、內部氣體檢測和紅外監測等頂級功能&#xff0c;可以顯著提升園區的安全管理水平和運維效率。以下是智慧井蓋系統的詳細設計方案和功能實現&#xff1a; 一、系統架構 智慧井蓋系統可以分為以下層次&#xff1a; 1. 感知層 定位模塊&#xff1…

零基礎deep seek+剪映,如何制作高品質的視頻短片

以下是專為零基礎學習者設計的 剪映專業版詳細教程&#xff0b;Deep seek配合制 &#xff0c;包含從入門到精通的系統化教學&#xff0c;配合具體操作步驟與實用技巧&#xff1a; 基于DeepSeek與剪映協同制作高品質視頻短片的專業流程指南&#xff08;2025年最新實踐版&#x…

PHP:IDEA開發工具配置XDebug,斷點調試

文章目錄 一、php.ini配置二、IDEA配置 一、php.ini配置 [xdebug] zend_extension"F:\wamp64\bin\php\php7.4.0\ext\php_xdebug-2.8.0-7.4-vc15-x86_64.dll" xdebug.remote_enable on xdebug.remote_host 127.0.0.1 xdebug.remote_port 9001 xdebug.idekey"…

改進YOLOv8模型的空間注意力機制研究:RFAConv的貢獻與實現

文章目錄 1. 背景介紹2. 什么是RFAConv?3. YOLOv8中的RFAConv實現3.1 RFAConv模塊設計3.2 在YOLOv8中集成RFAConv4. 性能對比與實驗結果4.1 實驗設置4.2 實驗結果5. 模型優化與調優5.1 調整RFAConv模塊的超參數5.2 數據增強策略5.3 更深層的注意力機制5.4 混合卷積與優化計算圖…

【Java】使用jdk自帶的zip壓縮實現任意文件壓縮打包下載功能(復制即用)

前言 在實際項目中&#xff0c;我們可能會接到將文件或者資料打包壓縮導出的需求&#xff0c;例如將系統中某些生成的文件一起打包壓縮下載提供給客戶使用&#xff0c;今天提供一個jdk自帶的工具類快速實現打包壓縮的功能&#xff0c;方法我已經封裝好&#xff0c;大家如果在項…

騰訊云擴容記錄

騰訊云擴容&#xff1a; sudo yum install -y cloud-utils-growpart 安裝擴容工具 sudo file -s /dev/vda1 有數據 sudo LC_ALLen_US.UTF-8 growpart /dev/vda 1 sudo resize2fs /dev/vda1 df -Th 完畢 以下是對執行的命令的詳細解釋以及背后的原理&#xff1a; 1. 安裝 cloud…

服務流程設計和服務或端口重定向及其websocket等應用示例

服務流程設計和服務或端口重定向及其websocket等應用示例 目錄 服務或端口重定向的服務設計和websocket等應用示例 一、通用請求控制流程 1.1、入口 1.2、所有GET請求首先預檢控制單元 1.3、http請求會分別自動307重定向 1.4、所有請求首先執行跨源控制單元 1.5、然后…

PHP面試題--后端部分

本文章持續更新內容 之前沒來得及整理時間問題導致每次都得找和重新背 這次整理下也方便各位小伙伴一起更輕松的一起踏入編程之路 歡迎各位關注博主不定期更新各種高質量內容適合小白及其初級水平同學一起學習 一起成為大佬 數組函數有那些 ps&#xff1a;本題挑難的背因為…

深入了解 MySQL 中的 JSON_CONTAINS

深入了解 MySQL 中的 JSON_CONTAINS MySQL 5.7 及更高版本引入了對 JSON 數據類型的支持&#xff0c;使得在數據庫中存儲和查詢 JSON 數據成為可能。在這些新功能中&#xff0c;JSON_CONTAINS 函數是一個非常有用的工具&#xff0c;允許我們檢查一個 JSON 文檔是否包含特定的值…