随笔分类 - 题解
1
摘要:农夫约翰最喜欢的操作 题目描述 农夫约翰有一个包含 N 个非负整数的数组 a 和一个整数 M。他希望通过对数组元素加 1 或减 1,使得存在某个整数 x,对于所有 1 ≤ i ≤ N,表达式 a[i] - x 都能被 M 整除。每次操作可以选择一个索引 i,将 a[i] 加 1 或减 1。农夫约翰的
阅读全文
摘要:题目链接d 题目分析 本题要求在一个简单连通无向图中,找出从顶点 1 到顶点 N 的所有简单路径(即不重复经过同一顶点的路径)中,路径上所有边的标签的异或值的最小值。 输入信息 第一行包含两个整数 N 和 M,分别表示图的顶点数和边数,其中 2 ≤ N ≤ 10,N - 1 ≤ M ≤ N * (N
阅读全文
摘要:P4994 终于结束的起点 题解 一、题目分析 本题给定一个正整数 M((2 <= M <= 706150)),任务是找出满足特定条件的最小正整数 n。这个条件是斐波那契数列的第 n 项 fib(n) 对 M 取模的结果为 0,并且第 (n + 1) 项 fib(n+1) 对 M 取模的结果为 1
阅读全文
摘要:比赛链接 A. Wrong Subtraction 给一个数n,俩操作执行k次: 个位不为0就减1 个位为0就除10 直接模拟,代码: #include<bits/stdc++.h> using namespace std; int main(){ int n,k;cin>>n>>k; while(
阅读全文
摘要:题目6118. 蛋糕游戏 题目分析 贝和埃分蛋糕,n个蛋糕,大小不一从a1到aN,两者轮流进行以下操作: 贝的操作: 她每次选择两个相邻的蛋糕,将它们堆叠成一个新的蛋糕,蛋糕的大小等于这两个蛋糕的和 埃的操作: 她每次选择最左边或最右边的一个蛋糕,将其藏起来 游戏结束时,剩下的唯一一个蛋糕由贝吃掉,
阅读全文
摘要:题目P6306 「Wdsr-1」小铃的书 题目分析 核心问题: 小铃的书有 n-1 本,编号满足每种编号的书的数量是 k 的倍数 混入了一本魔理沙的魔导书(编号未知),现在总共有 n 本书 我们需要找出这本魔导书的编号 性质分析: 由于小铃的书编号数量满足倍数关系,每种编号的书的数量在 n-1 本书
阅读全文
摘要:题目:P1470 [USACO2.3] 最长前缀 Longest Prefix 题目解析 问题描述 给定一个元素集合 ( P ) 和一个大写字母序列 ( s ),要求找到 ( s ) 的最长前缀 ( s' ),使得 ( s' ) 可以由 ( P ) 中的元素组成。元素可以重复使用,但不一定要全部出现
阅读全文
摘要:题目P2569 [SCOI2010] 股票交易 问题描述 我们需要帮助lxhgww制定一个交易策略,使得在 T 天内赚到最多的钱。每天的交易有以下限制: 第 i天的买入价为 AP_i,卖出价为 BP_i,且AP_i≥BP_i 第 i 天的买入上限为 AS_i,卖出上限为 BS_i 两次交易之间至少要
阅读全文
摘要:题目链接:https://leetcode.cn/problems/identify-the-largest-outlier-in-an-array/description/ 题解代码: class Solution { public: int getLargestOutlier(std::vect
阅读全文
摘要:1456.定长子串中元音的最大数目 题目链接:https://leetcode.cn/problems/maximum-number-of-vowels-in-a-substring-of-given-length/description/ 题解代码: class Solution { public
阅读全文
摘要:B2. The Strict Teacher (Hard Version) 题目链接:https://codeforces.com/contest/2005/problem/B2 题解代码: #include<bits/stdc++.h> using namespace std; int main(
阅读全文
摘要:元素和小于等于 k 的子矩阵的数目 题目链接:https://leetcode.cn/problems/count-submatrices-with-top-left-element-and-sum-less-than-k/description/ 题解代码: class Solution { pu
阅读全文
摘要:1108.IP 地址无效化 题目链接:https://leetcode.cn/problems/defanging-an-ip-address/description/ 题解代码: class Solution { public: string defangIPaddr(string address
阅读全文
摘要:504.七进制数 题目链接:https://leetcode.cn/problems/base-7/description/ 题解代码: class Solution { public: string convertToBase7(int num) { string nums; int a=abs(
阅读全文
摘要:1109.航班预订统计 题目链接:https://leetcode.cn/problems/corporate-flight-bookings/description/ 题解代码: class Solution { public: vector<int> corpFlightBookings(vec
阅读全文
摘要:零数组变换 I 题目链接:https://leetcode.cn/problems/zero-array-transformation-i/description/ 题解代码: class Solution { public: bool isZeroArray(vector<int>& nums,
阅读全文
摘要:题目链接:https://www.luogu.com.cn/problem/P1102 题解代码: //双指针 #include<bits/stdc++.h> using namespace std; const int MAX = 2 * 10e5 + 10; int n, c, nums[MAX
阅读全文
摘要:题目链接:https://www.luogu.com.cn/problem/P2249 题解代码: #include<iostream> using namespace std; int n, m, q, a[1000005]; int find(int x); int main() { cin >
阅读全文
摘要:题目链接:https://leetcode.cn/problems/adjacent-increasing-subarrays-detection-ii/ 题解代码: int maxIncreasingSubarrays(int* nums, int numsSize) { int ans = 0,
阅读全文
摘要:题目链接: https://leetcode.cn/problems/minimum-element-after-replacement-with-digit-sum/ 题解代码: int minElement(int* nums, int numsSize) { int temp=10000; w
阅读全文
1