POJ - 3842 An Industrial Spy dfs(水)】的更多相关文章

题意:给你一串数字,最少一个,最多七个,问用这里面的数字能组成多少素数,不重复. 思路:之前还遍历10000000的每一个素数,结果超时,后来发现直接dfs就可以了,只是标记一下做过的数. #pragma comment(linker, "/STACK:1000000000") #include <bits/stdc++.h> #define LL long long #define INF 0x3f3f3f3f #define IN freopen("in.tx…
An Industrial Spy   Description Industrial spying is very common for modern research labs. I am such an industrial spy - don't tell anybody! My recent job was to steal the latest inventions from a famous math research lab. It was hard to obtain some…
POJ 1321-棋盘问题 K - DFS Time Limit:1000MS     Memory Limit:10000KB     64bit IO Format:%I64d & %I64u   Description 在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子,棋子没有区别.要求摆放时任意的两个棋子不能放在棋盘中的同一行或者同一列,请编程求解对于给定形状和大小的棋盘,摆放k个棋子的所有可行的摆放方案C. Input 输入含有多组测试数据. 每组数据的第一行是两个正整数,n k…
题目描述: Description Given a specified total t and a list of n integers, find all distinct sums using numbers from the list that add up to t. For example, if t = 4, n = 6, and the list is [4, 3, 2, 2, 1, 1], then there are four different sums that equal…
Description There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can move only…
枚举点 每次都搜一遍 //By SiriusRen #include <cstdio> #include <cstring> #include <algorithm> using namespace std; #define N 20005 int ans,k,n,m,first[N],next[N],v[N],tot,xx,yy,mark[N],vis[1005]; void add(int x,int y){ v[tot]=y,next[tot]=first[x],…
题目链接:http://poj.org/problem?id=1321 很久没有敲搜索了啊,今天敲了个水题练练手,哈哈.... 题目大意: 就是求在n*n的方格上放置k个棋子的方案数 代码: #include<iostream> #include<cstdlib> #include<cstring> #include<cstdio> using namespace std; int n,k; ][]; ]; int sum; int ans; bool Ju…
链接:http://poj.org/problem?id=2386 题解 #include<cstdio> #include<stack> using namespace std; ,MAX_N=; char a[MAX_N][MAX_M]; int N,M; //现在位置 (x,y) void dfs(int x,int y){ a[x][y]='.'; //将现在所在位置替换为'.',即旱地 ;dx<=;dx++){ //循环遍历连通的8个方向:上.下.左.右.左上.左下…
http://wikioi.com/problem/1229/ 赤裸裸的水题啊. 一开始我认为不用用完全部的牌,以为爆搜会tle.. 可是我想多了. 将所有状态全部求出,排序后暴力判断即可. (水题有点严重啊) #include <cstdio> #include <algorithm> using namespace std; int n, m; int h[440000], cnt, a[12]; bool vis[12]; void dfs(int x, int sum, i…
Apple Tree Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 25904   Accepted: 7682 Description There is an apple tree outside of kaka's house. Every autumn, a lot of apples will grow in the tree. Kaka likes apple very much, so he has been…