Skip to content

Commit d1136ac

Browse files
committed
feat: 添加公式支持
1 parent 95a0ed8 commit d1136ac

File tree

1 file changed

+37
-0
lines changed
  • content/blog/soft-enginering-exam

1 file changed

+37
-0
lines changed

content/blog/soft-enginering-exam/index.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ date: 2025-11-26T18:54:00+08:00
44
draft: false
55
tags: ["福州大学" ,"转专业" ,"C++", "Python", "算法"]
66
---
7+
{{< katex >}}
78

89
> Cai觉得有必要重温的题目.jpg
910
> 解答均为Cai自己写的,不代表最优解
@@ -2196,8 +2197,44 @@ int main()
21962197

21972198
### 1. [Lutece 167 a ^ b](https://cdoj.site/d/lutece/p/Lutece0167)
21982199

2200+
思路:`Python`自带快速幂`pow`,然后补位用`rjust`,注意保留k位应该取模`10**k`
2201+
2202+
```python
2203+
n=int(input())
2204+
2205+
for _ in range(n):
2206+
a,b=map(int,input().split())
2207+
c=pow(a,b,10**4)
2208+
print(str(c).rjust(4,"0"))
2209+
```
2210+
21992211
### 2. [最大子数组和](https://leetcode.cn/problems/maximum-subarray/description/)
22002212

2213+
思路:看题解做的(真的不会`dp`啊啊啊啊),发现题解的思路好精妙,遍历每个数然后求和并且更新最大值,当和小于等于`0`时就直接重置和,也就是开始重新寻找子数组,这样时间复杂度只有`O(n)`
2214+
2215+
```cpp
2216+
class Solution {
2217+
public:
2218+
int maxSubArray(vector<int>& nums) {
2219+
int sum=0;
2220+
int max_sum=INT_MIN;
2221+
for (int i=0;i<nums.size();i++)
2222+
{
2223+
sum+=nums[i];
2224+
if (sum>max_sum)
2225+
{
2226+
max_sum=sum;
2227+
}
2228+
if (sum<=0)
2229+
{
2230+
sum=0;
2231+
}
2232+
}
2233+
return max_sum;
2234+
}
2235+
};
2236+
```
2237+
22012238
### 3. [兔子试毒](https://www.luogu.com.cn/problem/T158663)
22022239
22032240
### 4. [淹没岛屿](https://www.luogu.com.cn/problem/P8662)

0 commit comments

Comments
 (0)