算法 第2页
令人头疼的算法,算法竞赛冲啊
【算法】【Python】N皇后问题的三种解法 - AI科研 编程 读书笔记 - 小竹の笔记本

【算法】【Python】N皇后问题的三种解法

本文分析了N皇后问题的三种解法:回溯法通过逐行尝试并安全检测实现,时间复杂度O(n!)但实现简单;分支限界法利用列和对角线标记数组将安全判断优化至O(1),通过空间换时间显著提升速度;位运算...
SmallBamboo的头像 - AI科研 编程 读书笔记 - 小竹の笔记本SmallBamboo5个月前
015515
【C】判断回文数 - AI科研 编程 读书笔记 - 小竹の笔记本

【C】判断回文数

#include <stdio.h> bool fun(int n) { int a = 0; int num = n; while (n > 0) { a = a * 10 + n % 10; n = n / 10; } if (a==num) { return true; } else { return false; } } int main() ...
SmallBamboo的头像 - AI科研 编程 读书笔记 - 小竹の笔记本SmallBamboo2年前
09715
【算法】【Python】蓝桥杯Python组比赛技巧 - AI科研 编程 读书笔记 - 小竹の笔记本

【算法】【Python】蓝桥杯Python组比赛技巧

本文介绍了Python在蓝桥杯比赛中的常用技巧,包括序列翻转、数字进制转换、数学表达式解析、自定义排序、遍历序列、数据结构操作、组合与排列生成、双端队列、阶乘计算、日期处理、字符计数、有...
SmallBamboo的头像 - AI科研 编程 读书笔记 - 小竹の笔记本SmallBamboo5个月前
08914
【模拟】二进制求和 - 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年前
014314
【C++】过河卒问题 - AI科研 编程 读书笔记 - 小竹の笔记本

【C++】过河卒问题

无马情况 #include <iostream> // 定义棋盘大小 #define MAXSIZE 30 using namespace std; int main(){ int a[MAXSIZE][MAXSIZE]={0}; int n,m; // n,m为B点的坐标,A点默认为(0,0) cin >> n...
SmallBamboo的头像 - AI科研 编程 读书笔记 - 小竹の笔记本SmallBamboo1年前
015614
【C】五舍六入? - AI科研 编程 读书笔记 - 小竹の笔记本

【C】五舍六入?

如果题目让你五舍六入,那么就没办法使用C++里的round函数了,只能选择一个通用的方法,示例如下: #include <stdio.h> #define PI 3.1415926 int main(){ double r,ans; scanf('%lf',&r...
SmallBamboo的头像 - AI科研 编程 读书笔记 - 小竹の笔记本SmallBamboo2年前
014813