uva-10167-枚举
题意:生日蛋糕上面有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-枚举的更多相关文章
- UVA - 10167 - Birthday Cake (简单枚举)
思路:简单枚举 AC代码: #include <cstdio> #include <cstring> #include <iostream> #include &l ...
- Uva 10167 - Birthday Cake 暴力枚举 随机
Problem G. Birthday Cake Background Lucy and Lily are twins. Today is their birthday. Mother buys ...
- Brute Force --- UVA 10167: Birthday Cake
Problem G. Birthday Cake Problem's Link:http://uva.onlinejudge.org/index.php?option=com_onlinejudg ...
- UVa 12169 (枚举+扩展欧几里得) Disgruntled Judge
题意: 给出四个数T, a, b, x1,按公式生成序列 xi = (a*xi-1 + b) % 10001 (2 ≤ i ≤ 2T) 给出T和奇数项xi,输出偶数项xi 分析: 最简单的办法就是直接 ...
- UVa 140 (枚举排列) Bandwidth
题意较复杂,请参见原题=_=|| 没什么好说的,直接枚举每个排列就好了,然后记录最小带宽,以及对应的最佳排列. STL里的next_permutation函数真是好用. 比较蛋疼的就是题目的输入了.. ...
- UVa 1151 (枚举 + MST) Buy or Build
题意: 平面上有n个点,现在要把它们全部连通起来.现在有q个套餐,如果购买了第i个套餐,则这个套餐中的点全部连通起来.也可以自己单独地建一条边,费用为两点欧几里得距离的平方.求使所有点连通的最小费用. ...
- uva 10167 - Birthday Cake
题解:由于解太多,随机抓 A.B, 只要有符合就行了: (首先,Ax+By=0必须表示直线,即A.B不能同时为0:另外,要注意到直线不能过输入中的2N个点:检测点在直线的哪一侧,只需要简单的线性规划的 ...
- Even Parity UVA - 11464 (枚举)
从来没有觉得枚举有多费脑子的.但是这道题还是很香的. 思路:就是非常简单的枚举啦. 从一般的枚举开始考虑.一般的做法就是在所有的格子中有两种状态1, 0. 而一共有225个格子,所有一共要枚举的情 ...
- UVa 1354 枚举子集 Mobile Computing
只要枚举左右两个子天平砝码的集合,我们就能算出左右两个悬挂点到根悬挂点的距离. 但是题中要求找尽量宽的天平但是不能超过房间的宽度,想不到要怎样记录结果. 参考别人代码,用了一个结构体的vector,保 ...
- Uva 11754(枚举+中国剩余定理)
#include<iostream> #include<cstdio> #include<cmath> #include<cstring> #inclu ...
随机推荐
- 多名历年高考状元最终选择做中国顶尖黑客 - imsoft.cnblogs
原标题:揭秘中国顶尖黑客:二分之一是历年高考[微博]状元 “二分之一是各地的历年高考状元,二分之一是数学专业,二分之一来自微软.” Keen这样的团队是坚决与黑产划清界限的,这也是圈内的“道德洁癖”, ...
- HDU - 2475:Box(splay维护森林)
There are N boxes on the ground, which are labeled by numbers from 1 to N. The boxes are magical, th ...
- 2018CCPC女生赛(树上莫队)
签到题这里久懒得写了. B - 缺失的数据范围 Total Submission(s): 2602 Accepted Submission(s): 559 题意:求最大的N,满足N^a*[log ...
- DZY Loves Math系列
link 好久没写数学题了,再这样下去吃枣药丸啊. 找一套应该还比较有意思的数学题来做. [bzoj3309]DZY Loves Math 简单推一下. \[\sum_{i=1}^n\sum_{j=1 ...
- jQuery插件制作方法详解
jQuery插件制作方法详解 jquery插件给我的感觉清一色的清洁,简单.如Jtip,要使用它的功能,只需要在你的元素的class上加 上Jtip,并引入jtip.js及其样式即可以了. ...
- LG2945 【[USACO09MAR]沙堡Sand Castle】
经典的贪心模型,常规思路:将M和B排序即可 看到没有人用优先队列,于是我的showtime到了 说下思路: 读入时将数加入啊a,b堆中,不用处理(二叉堆本来就有有序的性质) 读完后逐个判断,照题目模拟 ...
- js 验证代码部分的简单实现
接上面的文章. 我们已经简单的设计了关于如何进行处理了,但是如何进行校验呢,代码也是比较简单的因为我们使用的是asp.net 简单并且功能强大. 我们同样使用的是HttpResponse,简单的模拟代 ...
- 创意:Soap一款新型的触摸式家用智能路由器
版权声明:本文为博主原创文章.未经博主同意不得转载. https://blog.csdn.net/iefreer/article/details/34808749 Soap简单介绍 这里的Soap不是 ...
- spring initializr 创建项目时,依赖对应的 artifactId
选择各个依赖时,对应的 artifactId 选择的依赖 artifactId名字 不选择依赖,默认包含的artifactId spring-boot-starter.spring-boot-star ...
- postman的Testing examples(测试脚本示例)
测试代码会在发送request并且接收到responses后执行. 1.设置环境变量 postman.setEnvironmentVariable("key", "val ...