题意:生日蛋糕上面有2N草莓,怎么切能够将蛋糕和草莓平分成俩份,直接枚举,A和B,草莓不能落在直线上

#include <iostream>
#include <stdio.h>
#include<memory.h>
using namespace std; #define null NULL
int N = 110;
int f(int a, int b, int x, int y)
{
return a * x + b * y;
}
int main(int argc, char* argv[])
{
//freopen("C:\\Users\\zzzzz\\Desktop\\1.txt", "r", stdin); int n;
int x[N];
int y[N];
while (cin >> n)
{
if (n == 0)
return 0;
for (int i = 0; i < 2 * n; i++)
cin >> x[i] >> y[i]; int ok = 1;
for (int a = -500; a <= 500 && ok; a++)
{
for (int b = -500; b <= 500 && ok; b++)
{
int l = 0, r = 0;
for (int i = 0; i < 2 * n; i++)
{
int k = f(a, b, x[i], y[i]);
if (k == 0)
break;
if (k < 0)
l++;
else
r++;
}
if (l == n && r == n)
{
cout << a << " " << b << endl;
ok = 0;
}
} }
}
return 0;
}

  

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

  1. UVA - 10167 - Birthday Cake (简单枚举)

    思路:简单枚举 AC代码: #include <cstdio> #include <cstring> #include <iostream> #include &l ...

  2. Uva 10167 - Birthday Cake 暴力枚举 随机

      Problem G. Birthday Cake Background Lucy and Lily are twins. Today is their birthday. Mother buys ...

  3. Brute Force --- UVA 10167: Birthday Cake

     Problem G. Birthday Cake  Problem's Link:http://uva.onlinejudge.org/index.php?option=com_onlinejudg ...

  4. UVa 12169 (枚举+扩展欧几里得) Disgruntled Judge

    题意: 给出四个数T, a, b, x1,按公式生成序列 xi = (a*xi-1 + b) % 10001 (2 ≤ i ≤ 2T) 给出T和奇数项xi,输出偶数项xi 分析: 最简单的办法就是直接 ...

  5. UVa 140 (枚举排列) Bandwidth

    题意较复杂,请参见原题=_=|| 没什么好说的,直接枚举每个排列就好了,然后记录最小带宽,以及对应的最佳排列. STL里的next_permutation函数真是好用. 比较蛋疼的就是题目的输入了.. ...

  6. UVa 1151 (枚举 + MST) Buy or Build

    题意: 平面上有n个点,现在要把它们全部连通起来.现在有q个套餐,如果购买了第i个套餐,则这个套餐中的点全部连通起来.也可以自己单独地建一条边,费用为两点欧几里得距离的平方.求使所有点连通的最小费用. ...

  7. uva 10167 - Birthday Cake

    题解:由于解太多,随机抓 A.B, 只要有符合就行了: (首先,Ax+By=0必须表示直线,即A.B不能同时为0:另外,要注意到直线不能过输入中的2N个点:检测点在直线的哪一侧,只需要简单的线性规划的 ...

  8. Even Parity UVA - 11464 (枚举)

    从来没有觉得枚举有多费脑子的.但是这道题还是很香的. 思路:就是非常简单的枚举啦.   从一般的枚举开始考虑.一般的做法就是在所有的格子中有两种状态1, 0. 而一共有225个格子,所有一共要枚举的情 ...

  9. UVa 1354 枚举子集 Mobile Computing

    只要枚举左右两个子天平砝码的集合,我们就能算出左右两个悬挂点到根悬挂点的距离. 但是题中要求找尽量宽的天平但是不能超过房间的宽度,想不到要怎样记录结果. 参考别人代码,用了一个结构体的vector,保 ...

  10. Uva 11754(枚举+中国剩余定理)

    #include<iostream> #include<cstdio> #include<cmath> #include<cstring> #inclu ...

随机推荐

  1. java正则表达式——Greedy、Reluctant和Possessive

    测试1: package jichu; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Mai ...

  2. CSU 1112: 机器人的指令

    1112: 机器人的指令 Submit Page          Description 数轴原点有一个机器人.该机器人将执行一系列指令,你的任务是预测所有指令执行完毕之后它的位置. ·LEFT:往 ...

  3. (4)socket的基础使用(基于TCP协议的并发编程)

    需要实现并发需要依靠socketserver 模块 socketserver模块下有几个功能 def __init__(self, request, client_address, server): ...

  4. (4)对象的的初始化与__init__方法以及绑定方法

    class OldboyStudent: # name='xxxx' # 相似的特征: school = 'oldboy' # 相似的技能 def choose_course(self): print ...

  5. HTML标签 select 里 动态添加option

    HTML标签 select 里 动态添加option: ☆ var today = new Date(); var yearNow = today.getFullYear(); var optiong ...

  6. Spark的启动进程详解

    Master和Worker是执行任务之前存在的进程 (类似于公司) Driver和Excutor是任务执行之后存在的进程(类似于公司接到项目后才成立的项目小组) 启动步骤: 启动Master资源管理进 ...

  7. 【转】每天一个linux命令(25):linux文件属性详解

    原文网址:http://www.cnblogs.com/peida/archive/2012/11/23/2783762.html Linux 文件或目录的属性主要包括:文件或目录的节点.种类.权限模 ...

  8. Thread.currentThread()与this的区别

    Thread.currentThread()与this的区别: Thread.currentThread()方法返回的是对当前正在执行的线程对象的引用,this代表的是当前调用它所在函数所属的对象的引 ...

  9. django模板里关闭特殊字符转换,在前端以html语法渲染

    变量 pagination_html是一个方法返回的html代码,需要在前端渲染出来,不是当字符串显示 <!-- /.box-body --> {% autoescape off %} { ...

  10. Visual Studio2010不能安装Silverlight4_Tools,提示语言不一致

    天在装Silverlight4_Tools时出现“必须先安装与 Silverlight Tools 4 语言版本相一致的 Visual Studio 2010.Visual Web Developer ...