算法 第2页
令人头疼的算法,算法竞赛冲啊
【DP】使用最小花费爬楼梯 - AI科研 编程 读书笔记 - 小竹の笔记本

【DP】使用最小花费爬楼梯

题目 给你一个整数数组 cost ,其中 cost[i] 是从楼梯第 i 个台阶向上爬需要支付的费用。一旦你支付此费用,即可选择向上爬一个或者两个台阶。 你可以选择从下标为 0 或下标为 1 的台阶开始爬楼...
SmallBamboo的头像 - AI科研 编程 读书笔记 - 小竹の笔记本SmallBamboo1年前
017310
【C】使用函数递归实现顺序数组二分查找 - AI科研 编程 读书笔记 - 小竹の笔记本

【C】使用函数递归实现顺序数组二分查找

#include <stdio.h> int BinarySearch(int r[],int low,int high,int k){ int mid; if (low>high){ //若找不到,则返回-1,这也是递归终止条件 return -1; } else{ mid=(low+high)/2; //在顺...
SmallBamboo的头像 - AI科研 编程 读书笔记 - 小竹の笔记本SmallBamboo1年前
016915
【C】对一个分数约分 - AI科研 编程 读书笔记 - 小竹の笔记本

【C】对一个分数约分

int gcd(int a, int b) {    if (b == 0) {        return a;   } else {        return gcd(b, a % b);   } } void simplifyFraction(int *a, int *b) {    int divisor = gcd(*...
SmallBamboo的头像 - AI科研 编程 读书笔记 - 小竹の笔记本SmallBamboo2年前
01659
【C】使用函数递归实现二分查找数组最大值 - AI科研 编程 读书笔记 - 小竹の笔记本

【C】使用函数递归实现二分查找数组最大值

#include <stdio.h> //二分查找最大值 int Max(int r[],int low,int high){ int mid,maxL,maxR; if (low==high){ return r[low]; } else{ mid=(high+low)/2; maxL=Max(r,low,mid); maxR=Max(...
SmallBamboo的头像 - AI科研 编程 读书笔记 - 小竹の笔记本SmallBamboo1年前
01659
【递归】2的幂 - AI科研 编程 读书笔记 - 小竹の笔记本

【递归】2的幂

递归法: class Solution:    def isPowerOfTwo(self, n: int) -> bool:        if n==1:            return True        if n<=0 or n%2!=0:            return Fals...
SmallBamboo的头像 - AI科研 编程 读书笔记 - 小竹の笔记本SmallBamboo1年前
016311
【模拟】回文日期 - AI科研 编程 读书笔记 - 小竹の笔记本

【模拟】回文日期

题目 我的代码 import datetime ipt = input() begin = datetime.datetime(int(ipt[0:4]), int(ipt[4:6]), int(ipt[6:8])) flag1=0 flag2=0 while True:  if flag1==1 and flag2==1:    brea...
SmallBamboo的头像 - AI科研 编程 读书笔记 - 小竹の笔记本SmallBamboo1年前
01637