题意:给出n个点,每个点上有一个数字可以0或1,然后给出m条限制,要求a和b两个点上的数字满足 a op b = c,op和c都是给定。问是否能够有一组解满足所有限制?(即点上的数字是0是1由你决定)思路:题意很清晰了,难点在建图。要考虑所有可能的冲突:当op为and: (1)c为0时,其中1个必....
分类:
其他好文 时间:
2015-07-10 20:30:12
阅读次数:
96
Description In an extended version of the game Lights Out, is a puzzle with 5 rows of 6 buttons each (the actual puzzle has 5 rows of 5 buttons each)....
分类:
其他好文 时间:
2015-07-10 15:06:19
阅读次数:
102
Write a program to solve a Sudoku puzzle by filling the empty cells.Empty cells are indicated by the character'.'.You may assume that there will be on...
分类:
其他好文 时间:
2015-07-09 12:41:17
阅读次数:
170
题意:连连看游戏,给定一个局面判断最后能不能消完。
思路:用dfs来确定消去哪一个格子(x,y),在dfs中进行bfs,看(x,y)周围有多少格子可以和(x,y)相消,找到之后再用dfs枚举与哪一个相消或者当前(x,y)不消。
注意一个剪枝,存在下面这种情况的肯定不符合题意:
*********
***AB***
***BA***
*********
另外,注意题意的消去方法,连线最多只转两个弯。...
分类:
其他好文 时间:
2015-07-06 23:33:47
阅读次数:
628
这题,简单的数学题。
对于函数,f(x)=5*x^13+13*x^5+k*a*x,输入k,对于任意的x,是否存在一个数a,使得f(x)被65整除。
对于任意的x。所以当x = 1时,f(x) = 18 + a* k,满足被65整除。
也就是(18 + a * k)% 65 = 0。
所以,一切都很简单了。
下面的是AC的代码:
#include
using namespace s...
分类:
其他好文 时间:
2015-06-29 00:35:23
阅读次数:
141
N-Queens
The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.
Given an integer n, return all distinct solutions ...
分类:
其他好文 时间:
2015-06-27 09:50:33
阅读次数:
120
分析:
简单的bfs,但要注意因为输入cases很多,对每个初始状态都搜一遍会超时,其实可以从终止状态反向搜一遍,对搜到的每个状态打表存下即可。
代码:
//poj 3221
//sep9
#include
#include
using namespace std;
int n;
int fac[]={1,1,2,6,24,120,720,5040,40320};
int vis[1...
分类:
其他好文 时间:
2015-06-26 09:27:18
阅读次数:
120
2031. Overturned Numbers
Time limit: 1.0 second
Memory limit: 64 MB
Little Pierre was surfing the Internet and came across an interesting puzzle:
What is the number under the car?
...
分类:
其他好文 时间:
2015-06-23 13:40:26
阅读次数:
146
输入特别坑,必须很小心,也不要想太复杂,开始N次WA,就是输入想太多
分类:
其他好文 时间:
2015-06-21 15:47:35
阅读次数:
123
Write a program to solve a Sudoku puzzle by filling the empty cells.Empty cells are indicated by the character'.'.You may assume that there will be on...
分类:
其他好文 时间:
2015-06-16 12:22:54
阅读次数:
104