算法 第5页
令人头疼的算法,算法竞赛冲啊
【模拟】二进制求和 - AI科研 编程 读书笔记 - 小竹の笔记本

【模拟】二进制求和

#include <iostream> using namespace std; string addBinary(string a, string b){ string res; int carry = 0;  // 进位 int i = a.size() - 1; int j = b.size() - 1; while(i >= 0 || j...
SmallBamboo的头像 - AI科研 编程 读书笔记 - 小竹の笔记本SmallBamboo1年前
013914
【C++】高精度减法 - AI科研 编程 读书笔记 - 小竹の笔记本

【C++】高精度减法

#include <iostream> using namespace std; int main(){ string s1,s2; cin >> s1; cin >> s2; int a1[210]={0}; int a2[210]={0}; int a3[210]={0}; char flag='+'; if (s1.size()<s2.si...
SmallBamboo的头像 - AI科研 编程 读书笔记 - 小竹の笔记本SmallBamboo1年前
013313
【算法】【Python】itertools包的妙用 - AI科研 编程 读书笔记 - 小竹の笔记本

【算法】【Python】itertools包的妙用

本文系统解析Python标准库itertools在算法竞赛中的高效应用,重点剖析排列组合、笛卡尔积、前缀和等核心功能。permutations处理全排列问题,combinations实现子集枚举,product替代多重嵌套循环...
SmallBamboo的头像 - AI科研 编程 读书笔记 - 小竹の笔记本SmallBamboo3个月前
01285
【算法】【Python】好数 - AI科研 编程 读书笔记 - 小竹の笔记本

【算法】【Python】好数

我的题解 def isGood(x): x = str(x) lenx = len(x) for i in range(lenx): # 奇数位 if i % 2 == 0: if int(x[-i-1]) % 2 == 0: return False else: if int(x[-i-1]) % 2 == 1: return False r...
SmallBamboo的头像 - AI科研 编程 读书笔记 - 小竹の笔记本SmallBamboo5个月前
01267
【算法】【Pyhton】走迷宫-广度优先搜索BFS求解最短路径 - AI科研 编程 读书笔记 - 小竹の笔记本

【算法】【Pyhton】走迷宫-广度优先搜索BFS求解最短路径

本文介绍利用广度优先搜索(BFS)算法求解迷宫最短路径的Python实现。通过读取用户输入的迷宫矩阵和起止坐标,程序使用队列结构逐层扩展探索路径。每次从队列取出当前坐标后,会向上下左右四个...
SmallBamboo的头像 - AI科研 编程 读书笔记 - 小竹の笔记本SmallBamboo3个月前
01248
【C】合并有序数组 - AI科研 编程 读书笔记 - 小竹の笔记本

【C】合并有序数组

#include <stdio.h> int main(){ int M,N; int a[]={1,3,5,6,8},b[]={1,2,5,7,8,9}; M=sizeof(a)/sizeof(a[0]); N=sizeof(b)/sizeof(b[0]); int c[M+N]; int i=0,j=0,k=0; //当有任何一个数...
SmallBamboo的头像 - AI科研 编程 读书笔记 - 小竹の笔记本SmallBamboo1年前
012211