avatar
fireworks99
keep hungry keep foolish
BFS路径输出

记录路径

pre存当前点的前一个点的位置标号(序号),类似的还有最长递增子序列的路径记录,还有链式前向星,都是一个方法。

Read more -->
uva 11624 Fire!

题意

帮助J走出一个大火蔓延的迷宫。J每分钟可以超上下左右四个方向移动,而所有着火的格子每一分钟都会往四个方向蔓延一格。迷宫中有一些障碍,J和火都无法进入。当J走出迷宫的边界时,逃离成功。

Read more -->
sprintf

头文件

#include

作用之一

数字转字符串

Read more -->
JAVA 大数

条件判断: JAVA中while(n-- > 0)异于c++的while(n--)

Prepare to Input

Scanner in = new Scanner(System.in);//in可换为cin或scan
//......
in.close();//in可换cin或scan
Read more -->
POJ 2635 The Embarrassed Cryptographer

Description

The young and very promising cryptographer Odd Even has implemented the security module of a large system with thousands of users, which is now in use in his company. The cryptographic keys are created from the product of two primes, and are believed to be secure because there is no known method for factoring such a product effectively.

Read more -->
同余(模)定理

同余定义(德国/高斯):

两个整数 a、b,如果他们同时除以一个自然数p,所得的余数相同,则称a,b对于模p同余,记作a≡b(mod p)。读作:a同余于b模m。

Read more -->
POJ 3279 Fliptile

关于翻转问题

例:给定一个01串,现有翻转规则:

翻转某一个位置时其后面2个位置也会跟着翻转,也就是每次翻转都会翻转3个连续的位置。要将01串全部翻转为0,求最小的翻转次数

形似这类题的问题叫做翻转问题,也可以叫开关问题

Read more -->
尺取法

尺取法

尺取,取的是 : 多段等效区间(等效体现在:满足题目要求)

某些时候需要保证数列的单调性才能使用

Read more -->
异或寻异

关于异或

a为任意数字:

0 ^ a = a

a ^ a = 0

Read more -->
SDUT Balloons 和 HDU 1241 Oil Deposits

题目共同解法

都是求某一类连接成块共有多少块,那么对每一块dfs,运行多少次dfs便有多少块

Description

Both Saya and Kudo like balloons. One day, they heard that in the central park, there will be thousands of people fly balloons to pattern a big image. They were very interested about this event, and also curious about the image. Since there are too many balloons, it is very hard for them to compute anything they need. Can you help them? You can assume that the image is an N\N matrix, while each element can be either balloons or blank. Suppose element A and element B* are both balloons. They are connected if:

Read more -->
Site by Baole Zhao | Powered by Hexo | theme PreciousJoy