uva-10167-枚举】的更多相关文章

思路:简单枚举 AC代码: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #include <cmath> using namespace std; int x[105], y[105]; int main() { int A, B, N; while(scanf("%d", &N), N) { for(int…
  Problem G. Birthday Cake Background Lucy and Lily are twins. Today is their birthday. Mother buys a birthday cake for them.Now we put the cake onto a Descartes coordinate. Its center is at (0,0), and the cake's length of radius is 100. There are 2N…
 Problem G. Birthday Cake  Problem's Link:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=13&problem=1108&mosmsg=Submission+received+with+ID+14413715 Mean: http://luckycat.kshs.kh.edu.tw/…
题意: 给出四个数T, a, b, x1,按公式生成序列 xi = (a*xi-1 + b) % 10001 (2 ≤ i ≤ 2T) 给出T和奇数项xi,输出偶数项xi 分析: 最简单的办法就是直接枚举a.b,看看与输入是否相符. #include <cstdio> + ; ; int T, x[maxn]; int main() { //freopen("12169in.txt", "r", stdin); scanf("%d",…
题意较复杂,请参见原题=_=|| 没什么好说的,直接枚举每个排列就好了,然后记录最小带宽,以及对应的最佳排列. STL里的next_permutation函数真是好用. 比较蛋疼的就是题目的输入了.. #include <bits/stdc++.h> using namespace std; ; ], letter[maxn]; ]; int main() { //freopen("in.txt", "r", stdin); && ] !…
题意: 平面上有n个点,现在要把它们全部连通起来.现在有q个套餐,如果购买了第i个套餐,则这个套餐中的点全部连通起来.也可以自己单独地建一条边,费用为两点欧几里得距离的平方.求使所有点连通的最小费用. 分析: 很明显,如果没有这些套餐的话,就是一个裸的MST. 可以枚举套餐的组合情况,然后把套餐中的边的权值置为0,再求MST. 在求MST的过程中,并不需要把所有的边都加进来.只要把原图的MST的那些边和套餐中的边加进来即可. 因为,对于不在原图的MST的边,购买套餐以后,按照权值排序,排在它之前…
题解:由于解太多,随机抓 A.B, 只要有符合就行了: (首先,Ax+By=0必须表示直线,即A.B不能同时为0:另外,要注意到直线不能过输入中的2N个点:检测点在直线的哪一侧,只需要简单的线性规划的知识) #include <cstdio> #include <cstdlib> ], y[]; int test(int A, int B, int N) { static int i, pos, neg, tmp; pos = , neg = ; *N-; i >= ; i-…
从来没有觉得枚举有多费脑子的.但是这道题还是很香的. 思路:就是非常简单的枚举啦.   从一般的枚举开始考虑.一般的做法就是在所有的格子中有两种状态1, 0. 而一共有225个格子,所有一共要枚举的情况就是2255我们大概粗略的计算一下10大约是23则,时间复杂度大概是1085而实际的情况比这个要高.肯定不行. 但是,通过打草稿发现,只要第一行确定了第二行一定是唯一的,同理第三行也是唯一的.这样的话直接枚举第一行就行了呀! #include<cstring> #include<iostr…
只要枚举左右两个子天平砝码的集合,我们就能算出左右两个悬挂点到根悬挂点的距离. 但是题中要求找尽量宽的天平但是不能超过房间的宽度,想不到要怎样记录结果. 参考别人代码,用了一个结构体的vector,保存每个集合合法方案的左右两端最长的距离. #include <cstdio> #include <cstring> #include <algorithm> #include <vector> #include <map> #include <…
#include<iostream> #include<cstdio> #include<cmath> #include<cstring> #include<algorithm> #include<queue> #include<map> #include<set> #include<vector> #include<cstdlib> #include<string> #de…