Skip to content

修复题目5的bug并添加完整测试用例#421

Open
51Roadfish wants to merge 1 commit intoHanchuanXu:mainfrom
51Roadfish:fix
Open

修复题目5的bug并添加完整测试用例#421
51Roadfish wants to merge 1 commit intoHanchuanXu:mainfrom
51Roadfish:fix

Conversation

@51Roadfish
Copy link

学号:2023112265
修改题目号:5

修改思路:

  1. 修复f数组初始化错误
    • 原代码:f[0] = 0
    • 修复:f[0] = 1(正确表示2^0 = 1)
  2. 修复遍历条件不完整
    • 原代码:i < nums.length-1会漏掉最后一个元素
    • 修复:完整遍历并在内部判断退出条件
  3. 修复贡献计算逻辑
    • 原代码:f[pos - i]
    • 修复:f[pos - i - 1]
  4. 修复取模操作错误
    • 原代码:使用除法/ P
    • 修复:使用取模% P
  5. 优化一些逻辑
    • 修改了一些代码以提高可读性
- 修复f数组初始化错误 - 修复幂次计算和取模操作 - 完善遍历条件和贡献计算逻辑 - 添加符合要求的测试类
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant