hdu 4499 Cannon(暴力)】的更多相关文章

题目链接:hdu 4499 Cannon 题目大意:给出一个n*m的棋盘,上面已经存在了k个棋子,给出棋子的位置,然后求能够在这种棋盘上放多少个炮,要求后放置上去的炮相互之间不能攻击. 解题思路:枚举行放的情况,用二进制数表示,每次放之前推断能否放下(会不会和已经存在的棋子冲突),放下后推断会不会互相攻击的炮,仅仅须要对每一个新加入的炮考虑左边以及上边就能够了. #include <cstdio> #include <cstring> #include <algorithm&…
题意:给定一个n*m个棋盘,放上一些棋子,问你最多能放几个炮(中国象棋中的炮). 析:其实很简单,因为棋盘才是5*5最大,那么直接暴力就行,可以看成一行,很水,时间很短,才62ms. 代码如下: #include <cstdio> #include <string> #include <cstdlib> #include <cmath> #include <iostream> #include <cstring> #include &…
题意:在n*m的方格里有t个棋子,问最多能放多少个炮且每一个炮不能互相攻击(炮吃炮) 炮吃炮:在同一行或同一列且中间有一颗棋子. #include <stdio.h> #include <iostream> #include <algorithm> #include <string.h> #include <queue> #include <math.h> #define M 50 #define LL long long using…
Cannon Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4499 Description In Chinese Chess, there is one kind of powerful chessmen called Cannon. It can move horizontally or vertically along the chess grid. At eac…
Cannon Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 965    Accepted Submission(s): 556 Problem Description In Chinese Chess, there is one kind of powerful chessmen called Cannon. It can move…
Cannon Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 21    Accepted Submission(s): 14 Problem Description In Chinese Chess, there is one kind of powerful chessmen called Cannon. It can move ho…
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=5091 Problem Description Recently, the γ galaxies broke out Star Wars. Each planet is warring for resources. In the Star Wars, Planet X is under attack by other planets. Now, a large wave of enemy spaces…
Bazinga Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5510 Description Ladies and gentlemen, please sit up straight. Don't tilt your head. I'm serious.For n given strings S1,S2,⋯,Sn, labelled from 1 to n, you…
Numbers Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5522 Description 给n个数A1,A2....An{A}_{1},{A}_{2}....{A}_{n}A​1​​,A​2​​....A​n​​,从中选3个位置不同的数A,B和C,问是否有一种情况满足A-B=C. Input There are multiple test cases, no mo…
题目链接:hdu 5077 NAND 题目大意:Xiaoqiang要写一个编码程序,然后依据x1,x2,x3的值构造出8个字符.如今给定要求生成的8个字符.问 说Xiaoqiang最少要写多少行代码.代码内容仅仅能为NAND操作和return操作,操作的变量能够是常数. 解题思路:输入总共就256中情况,所以暴力剪枝打表,打表的代码手贱给删了...所以就将一下思路.开一个s数组 表示变量,然后相应每一层每次两个变量进行NAND操作. 大致三个剪枝,dfs时候,变量出现同样就跳过.8个字符能够直接…
GCD/center> 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5726 Description Give you a sequence of N(N≤100,000) integers : a1,...,an(0<ai≤1000,000,000). There are Q(Q≤100,000) queries. For each query l,r you have to calculate gcd(al,,al+1,...,ar) a…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4291 思路:首先保留求出循环节,然后就是矩阵求幂了. #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; typedef __int64 ll; #define MOD2 1000000007 #define MOD1 222…
因为题目当中的k比较小k <= 10,所以可以直接枚举,题目里面由两个trick, 一个是如果每个点都可以放稻草人的话,那么答案是0, 另外一个就是如果可以放稻草人的点不用被照到.知道了这两个基本上暴力既可以ac了 #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; ; struct Point { int…
USACO ORZ Time Limit: 5000/1500 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2291    Accepted Submission(s): 822 Problem Description Like everyone, cows enjoy variety. Their current fancy is new shapes for pastur…
题目:Click here 题意:给你n个点,有多少个正多边形(3,4,5,6). 分析:整点是不能构成正五边形和正三边形和正六边形的,所以只需暴力枚举四个点判断是否是正四边形即可. #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #define power(x) ((x)*(x)) using names…
odds Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 250    Accepted Submission(s): 72 Problem Description 度度熊有一棵 N 个节点 (node) 的有根树 (rooted tree),树上的每条边 (edge) 都有一个整数的权重,对于每一个非叶的节点 (non-leaf n…
为甚么16年Qingdao Online 都是暴力题emm///... 先暴力预处理 然后lower _bound二分 #include <iostream> #include <cstdio> #include <sstream> #include <cstring> #include <map> #include <cctype> #include <set> #include <vector> #incl…
面试n个人,可以分任意组数,每组选一个,得分总和严格大于k,问最少分几组 就是暴力嘛...想到就去写吧.. #include <iostream> #include <cstdio> #include <sstream> #include <cstring> #include <map> #include <set> #include <vector> #include <stack> #include <…
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=2089 不要62 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 54847    Accepted Submission(s): 21063 Problem Description 杭州人称那些傻乎乎粘嗒嗒的人为62(音:laoer).杭州交…
Chip Factory Time Limit: 18000/9000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 5394    Accepted Submission(s): 2422 Problem Description John is a manager of a CPU chip factory, the factory produces lots of chi…
TIANKENG manages a restaurant after graduating from ZCMU, and tens of thousands of customers come to have meal because of its delicious dishes. Today n groups of customers come to enjoy their meal, and there are Xi persons in the ith group in sum. As…
先来看看比较显然的几个局面 (a,0) 先手必败 (a,a) 先手必胜 (a,ak) 先手必胜 (a,ak+r),k>1 先手必胜,因为先手有主动权把(a,r)让给后手或留给自己 对于开局(a,r),r<a&&a/r<2,比较难分析,我们用暴力直接跑出结果 挑战程序设计竞赛把这种主动权成为自由度,名字真高端 这次的代码写的不怎么简练,不过能AC #include<iostream> #include<algorithm> #include<c…
Shopping Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 758    Accepted Submission(s): 254 Problem Description You have just moved into a new apartment and have a long list of items you need t…
题意:数独. 析:由于只是4*4,完全可以暴力,要注意一下一些条件,比如2*2的小方格也得是1234 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib> #include <cmath> #include <iostream> #include &…
题意:给定一篇文章,将每个单词的首尾字母不变,中间顺序打乱,然后将单词之间的空格去掉,得到一个序列,给出一个这样的序列,给你一个字典,将原文翻译出来. 析:在比赛的时候读错题了,忘记首尾字母不变了,一直WA.暴力求解,去深搜每个单词,做一些恰当的优化,能不进行的就不进行.胡搞的. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <strin…
Avin is studying series. A series is called "wave" if the following conditions are satisfied: 1) It contains at least two elements; 2) All elements at odd positions are the same; 3) All elements at even positions are the same; 4) Elements at odd…
题意:给出一个数n,问n能否是斐波那契数列中数的乘积 先刷选 斐波那契数列,然后就枚举 #include <cstdio> #include <cstring> #include <queue> #include <map> #include <iostream> using namespace std; typedef long long LL; ; LL num[]; map<LL, bool> m; void init() {…
字符串匹配函数strcmp 直接使用来判断两字符串是否完全相等 用数组存每个单词的个数时  初始化为零就错 初始化为一时就正确  也不知道为什么…
题意:给定n,k,l,接下来给出n个数,让你从n个数中选取k个数围成一圈,然后从这k个数中随意选出连续的m(m>=1&&m<=k)个数进行异或后得到[l,r]区间的所有值,让你求最大的r. 分析:关键问题是需要剪枝! 代码实现: #include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #inclu…
题意:在矩阵中,找一条路从 (1,1)->(n,m),使方差最小 思路: T = (N+M−1)∑N+M−1i=1(Ai−Aavg)2 将N + M - 1乘进去,即求1 ~ N+M-1,(N + M - 1)*A[i] - (A[i] + ..... + A[N]) 的和由于 假设Aavg可以是任何数,但只有当其是平均值时T才会最小(感觉别人都好厉害 /(ㄒoㄒ)/~~) #include <iostream> #include <cstdio> #include <…