题意:生日蛋糕上面有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. 在VM上安装centOS后的网络配置

    花了点时间,研究了下VM上的linux虚拟机的网络配置问题.1.环境主机:winXP SP2,家庭宽带,局域网连到路由器,ip地址为192.168.1.101. 虚拟机:centOS(redhat l ...

  2. 利用Fierce2查询子域名

    http://pnig0s1992.blog.51cto.com/393390/368428 安装方法引用Mickey的: 1.Mickey@pentestbox:/pentest/enumerati ...

  3. File、Directory、Path

    File.Directory.Path https://blog.csdn.net/xiaouncle/article/details/52050577 File.Directory.Path是实际开 ...

  4. linux下普通用户无法使用sudo命令问题

    今天在新装的linux虚拟机中使用sudo命令时,报错如下 We trust you have received the usual lecture from the local System Adm ...

  5. 如何调优JVM

    堆设置 -Xmx3550m:设置JVM最大堆内存 为3550M. -Xms3550m:设置JVM初始堆内存 为3550M.此值可以设置与-Xmx相同,以避免每次垃圾回收完成后JVM重新分配内存. -X ...

  6. TensorFlow 官方文档中文版学习

    TensorFlow 官方文档中文版 地址:http://wiki.jikexueyuan.com/project/tensorflow-zh/

  7. Python–logging模块知多少

    我们在写程序的时候经常会打一些日志来帮助我们查找问题,这次学习一下logging模块,在python里面如何操作日志. 介绍一下logging模块,logging模块就是python里面用来操作日志的 ...

  8. ThinkPHP 5 中的 composer.json

    本篇并不是揭 ThinkPHP 5 的问题. 只是通过 composer.json 来学习 compoer.json 元旦那天, ThinkPHP 5.1 正式发布,值得庆祝. 之后的第二天有人反馈 ...

  9. FineUI4.0以后如何调用JS事件

    F.ready(function() { // 你的代码 }); F.ready(function () {            var searchClientID = '<%= TextB ...

  10. Rockchip parameter文件详解

    瑞芯微的安卓平台使用 parameter 文件来配置一些系统参数,比如定义串口号,固件版本,flash分区信息等. parameter 文件是由 BootLoader 解析的,大小不能超过 64 KB ...