素数 埃氏筛 欧拉筛(线性筛) 【素数筛】 埃氏筛 欧拉筛(线性筛) 素数筛是一种用来筛选自然数n以内全部素数的算法。 埃氏筛 (Sieve of Eratosthenes) 埃氏筛的原理很容易理解,任意一个合数都可以表示成一个自然数i和一个素数的乘积,因此,如上图,筛出素数的倍数,剩下的就是素数。 代码//在primes中值为true的是合数 bool primes[MAXN] = {1, 1, 2019-11-06 算法 素数筛 欧拉筛 埃氏筛 数论
POJ 1426 Find The Multiple 【POJ】1426 Find The Multiple (BFS/DFS) 题目链接:poj-1426 Description Given a positive integer n, write a program to find out a nonzero multiple m of n whose decimal representation contains only the digits 2019-11-04 算法 DFS POJ BFS
POJ 3278 Catch That Cow 【POJ】 3278 Catch That Cow (BFS + 剪枝) 题目链接:poj 3278 DescriptionFarmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a point N (0 ≤ N ≤ 100,0 2019-11-03 算法 POJ BFS 剪枝
POJ 2251 Dungeon Master 【POJ】 2251 Dungeon Master (BFS) 题目链接:poj-2251 Description You are trapped in a 3D dungeon and need to find the quickest way out! The dungeon is composed of unit cubes which may or may not be filled w 2019-11-02 算法 POJ BFS
POJ 1321 棋盘问题 【POJ】1321 棋盘问题 (DFS) 题目链接:poj-1321 Description 在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子,棋子没有区别。要求摆放时任意的两个棋子不能放在棋盘中的同一行或者同一列,请编程求解对于给定形状和大小的棋盘,摆放k个棋子的所有可行的摆放方案C。 Input 输入含有多组测试数据。每组数据的第一行是两个正整数,n k,用一个空格隔开,表示了将 2019-11-01 算法 DFS POJ
leetcode单向链表[206, 24, 141, 142, 25] 【leetcode】链表题目训练[206, 24, 141, 142, 25]题目一:206. Reverse Linked List 题目:Reverse a singly linked list. 理解:反转一个单项链表 难度:easy 解法: 思路:头节点开始依次往后遍历链表,并更改每一个节点的next指针为前一个结点的地址 代码 class Solution { p 2019-10-02 数据结构 单向链表 数据结构 Leetcode