会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
Hu_YaYa
博客园
首页
新随笔
联系
订阅
管理
上一页
1
···
4
5
6
7
8
9
10
11
12
···
19
下一页
2020年4月10日
1089 Insert or Merge (25分)【归并排序、插入排序】
摘要: 1089 Insert or Merge (25分) According to Wikipedia: Insertion sort iterates, consuming one input element each repetition, and growi...
阅读全文
posted @ 2020-04-10 17:40 Hu_YaYa
阅读(14)
评论(0)
推荐(0)
2020年4月7日
扩展欧几里得算法(详细推导+代码实现+应用)
摘要: 1.扩展欧几里得算法 贝祖定理:若a,b是整数,且gcd(a,b)=d,那么对于任意的整数x,y,ax+by=m中的m一定是d的倍数。(特别地,如果a、b是整数,那么一定存在整数x、y使得ax+by=gcd(a,b)。) 那么贝祖定理的一个直接应用就是:如果ax+by=1有解,那么gcd(a,b)=
阅读全文
posted @ 2020-04-07 20:05 Hu_YaYa
阅读(577)
评论(0)
推荐(0)
2020年3月15日
大数的运算(详细思路+代码)
摘要: 大整数的存储 我们可以定义一个结构体来存储: struct bigNum{ int d[1000]; //存储大整数 int len; //大整数的长度 bigNum() { memset(d, 0, sizeof(d)); len = 0; } }; 在我们输入大数时,一般先用字符串读入,然后再把
阅读全文
posted @ 2020-03-15 18:28 Hu_YaYa
阅读(183)
评论(0)
推荐(0)
2020年3月14日
埃氏筛、欧拉筛
摘要: 前言 对于1~n范围内素数的查找,我们常用的二重循环暴力算法的复杂度是O(n2),如果利用开根缩小范围的时间复杂度也无非是在O( n n n\sqrt n nn ),而,这些算法对于n在105以内都是可以接受的,但是如果需要更大范围的素数表,这些算法将显得力不从心。下面将介绍更加高效的算法。 埃氏
阅读全文
posted @ 2020-03-14 11:07 Hu_YaYa
阅读(118)
评论(0)
推荐(0)
2020年3月13日
最大公约数和最小公倍数
摘要: 最大公约数 假设用gcd(a,b)来表示a和b的最大公约数。 首先认识一个定理: 假设a、b均为正整数,则gcd(a, b) =gcd(b, a%b)。 证明: 设a = kb + r,其中k和r分别为a除以b得到的商和余数。 则有r = a - kb成立。 设d为a和b的一个公约数, 那么由r =
阅读全文
posted @ 2020-03-13 15:39 Hu_YaYa
阅读(26)
评论(0)
推荐(0)
2020年3月11日
1044 Shopping in Mars (25分)【元素查找】
摘要: 1044 Shopping in Mars (25分) Shopping in Mars is quite a different experience. The Mars people pay by chained diamonds. Each diamon...
阅读全文
posted @ 2020-03-11 17:56 Hu_YaYa
阅读(9)
评论(0)
推荐(0)
1085 Perfect Sequence (25分)【二分法】
摘要: 1085 Perfect Sequence (25分) Given a sequence of positive integers and another positive integer p. The sequence is said to be a per...
阅读全文
posted @ 2020-03-11 13:35 Hu_YaYa
阅读(18)
评论(0)
推荐(0)
2020年3月10日
快速幂、矩阵快速幂(原理+模板)
摘要: 快速幂 首先,快速幂是用来解决什么问题的? 给定三个正整数a、b、m(a<109,b<1018,1<m<109),求ab%m 对于这个问题,如果使用暴力来处理显然是不行的,O(b)的复杂度支持b<108都已经很艰难了,更何况1018 快速幂的做法是基于二分的思想,因此也常称为二分幂。快速幂基于一下事
阅读全文
posted @ 2020-03-10 22:16 Hu_YaYa
阅读(225)
评论(0)
推荐(0)
1038 Recover the Smallest Number (30分)【贪心】
摘要: 1038 Recover the Smallest Number (30分) Given a collection of number segments, you are supposed to recover the smallest number from...
阅读全文
posted @ 2020-03-10 15:21 Hu_YaYa
阅读(22)
评论(0)
推荐(0)
1067 Sort with Swap(0, i) (25分)【贪心】
摘要: 1067 Sort with Swap(0, i) (25分) Given any permutation of the numbers {0, 1, 2,..., N−1}, it is easy to sort them in increasing ord...
阅读全文
posted @ 2020-03-10 14:42 Hu_YaYa
阅读(38)
评论(0)
推荐(0)
上一页
1
···
4
5
6
7
8
9
10
11
12
···
19
下一页
公告