位运算的简单应用

基本概念

  • int a = 1; 变量a实际的表示为0000…0001,共32位
  • 右移>>n位:去掉二进制后的n位
  • 左移<<n位:在二进制数后面填上n个0,$(1 << n = 2^n)$
  • 按位与或非

前缀树Trie入门专题

Trie简介

从根节点开始,将单词的每一个字符依次插入树,相同的前缀不重复插入,这样形成的树我们称为前缀树或者叫字典树(Trie)。例如下面的前缀树:


山东大学(威海)程序设计竞赛2020新星赛(线上模拟赛)题解

factorial(数论,简单模拟)

In many applications very large integers numbers are required. Some of these applications are using keys for secure transmission of data, encryption, etc. In this problem you are given a number, you have to determine the number of digits in the factorial of the number.


欧拉线性素数筛(转)

简介

在埃氏筛中,我们会重复筛到同一个数,例如12同时被2和3筛到,15同时被3和5筛到。所以我们引入欧拉筛,也叫线性筛,可以在$O(n)$的时间内完成对2~n的筛选。它的核心思想是:让每一个最小的合数被其最小质因数筛到


(数论)康托展开和逆康托展开

简介

康托展开是一个全排列到自然数的双射,常用于构建hash表来实现空间压缩。设$n$个数$(1,2,3,4,\cdots n)$,可以组成$n!$种排列,康托展开表示的就是当前的排列在所有组合中的名次。


Prime Path-POJ3126广搜

题目描述

hh学长酷爱素数,他经常自娱自乐,随机挑选两个四位的素数a,b。
游戏规则是:a可以通过改变某一位上的数字使其变成c,但只有当c也是四位的素数时才能进行这种改变。


埃式素数筛

原理

这是最简单的素数筛,一次性打表,效率不是很高,但是比直接判断素数效率高得多。反正开O2冲就完事了。


迷宫问题-POJ3984-路径输出

题目描述

定义一个二维数组:


Ctach That Cow-一维广搜

题目描述

Farmer 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,000) on a number line and the cow is at a point K (0 ≤ K ≤ 100,000) on the same number line. Farmer John has two modes of transportation: walking and teleporting.


Dungeon Master-POJ2251三维广搜

题目描述

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 with rock. It takes one minute to move one unit north, south, east, west, up or down. You cannot move diagonally and the maze is surrounded by solid rock on all sides.


Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×