[ZOJ 1003] Crashing Balloon (dfs搜索)】的更多相关文章

题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=3 题目大意:给你a,b两个数,问当b由约数1到100组成时,a能否由其它约数也在1到100的组成 就是dfs先枚举b的乘积组合,再看a有没有组合能够乘出来.. 代码: #include <cstdio> #include <cstdlib> #include <string> #include <iostream> #includ…
#include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using namespace std; int n,m; int flag1,flag2; void dfs(int a,int b,int x) { ) { flag2=; ) flag1=; } if(flag1&&flag2) return; ) return; ) dfs(a/x,b,x-);…
ZOJ Problem Set - 1003 Crashing Balloon Time Limit: 2 Seconds      Memory Limit: 65536 KB On every June 1st, the Children's Day, there will be a game named "crashing balloon" on TV.   The rule is very simple.  On the ground there are 100 labeled…
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=3 题意(难以描述):A,B两个人从1~100选数乘起来比谁的大(不能选重复的或者对方选的).数小的人如果发现数大的人在撒谎,则他可以获胜.(当然都没撒谎大数赢,都撒谎了也是大数赢233)而他判断大数撒谎的方法就是找到自己选的一个数,是构成大数所必须的./*给你两个数,由1~100选取不重复的数乘起来得到的.如果小的那个数包含了某个大数必须包含的因子,则*/ 题解:从1到100…
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1008 题目大意:给你n*n的矩阵,每个格子里有4个三角形,分别是上右下左,每个三角形里面标记了数字,问你能否通过移动这n*n个格子,使得相邻两个三角形具有相同的数字? dfs暴搜,dfs(x,y)代表当前要放(x,y)这个位置. 然后枚举给定的每个格子. 如果说可以放,就dfs下一个格子. 这一道题需要把相同的格子压缩起来,也就是说为了节省时间,可以记录相同的格…
考察DFS的应用,判断两个数的因子. #include <stdio.h> int f1,f2; void DFS(int m,int n,int k){ ){ f2=; ) f1=; } ) return; ) DFS(m/k,n,k-); ) DFS(m,n/k,k-); DFS(m,n,k-); } int main(){ int a,b,temp; ){ if(a<b){ temp=a; a=b; b=temp; } f1=f2=; DFS(a,b,); temp=(!f1&am…
Crashing Balloon Time Limit: 2 Seconds      Memory Limit: 65536 KB On every June 1st, the Children's Day, there will be a game named "crashing balloon" on TV.   The rule is very simple.  On the ground there are 100 labeled balloons, with the num…
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1011 题目大意:在一棵树上,给你起始状态,问你能否到达终止状态. 给了树的前序遍历序. 直接dfs搜索. #include <cstdio> #include <cstdlib> #include <string> #include <iostream> #include <cstring> #include &…
题目概述:Crashing Balloon On every  June 1st, the Children's Day, there will be a game named "crashing balloon" on  TV.   The rule is very simple.  On the ground there are 100 labeled balloons,  with the numbers 1 to 100. After the referee shouts &q…
Crashing Balloon Time Limit: 2 Seconds      Memory Limit: 65536 KB On every June 1st, the Children's Day, there will be a game named "crashing balloon" on TV.   The rule is very simple.  On the ground there are 100 labeled balloons, with the num…