算法 第5页
令人头疼的算法,算法竞赛冲啊
【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年前
015714
【C】时间差计算(表达式:运算符和算子,取余运算) - AI科研 编程 读书笔记 - 小竹の笔记本

【C】时间差计算(表达式:运算符和算子,取余运算)

时间差计算代码 //计算时间差 #include<stdio.h> int main() { int hour1,minute1,hour2,minute2; printf('请输入第一个时间\n'); scanf('%d %d', &hour1,&minute1); printf('请输入...
SmallBamboo的头像 - AI科研 编程 读书笔记 - 小竹の笔记本SmallBamboo2年前
04518
【递归】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年前
016411
【C】五舍六入? - AI科研 编程 读书笔记 - 小竹の笔记本

【C】五舍六入?

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

【算法】【Python】二维差分数组与其前缀和(洛谷P3397 地毯)

本文讨论了洛谷P3397题“地毯覆盖计数”的两种解法。作者最初用C语言暴力模拟遍历每个地毯覆盖的矩形区域,逐个累加计数,虽通过测试但效率较低。针对大规模数据(n、m≤1000),提出基于二维差...
SmallBamboo的头像 - AI科研 编程 读书笔记 - 小竹の笔记本SmallBamboo6个月前
011815
【C++】高精度加法 - AI科研 编程 读书笔记 - 小竹の笔记本

【C++】高精度加法

#include <iostream> using namespace std; int main(){ string s1,s2; //设置最大位数 int a1[210],a2[210],a3[210]={0}; //cin >> s1; //cin >> s2; getline(cin,s1); getline(cin,s2); //...
SmallBamboo的头像 - AI科研 编程 读书笔记 - 小竹の笔记本SmallBamboo1年前
0858