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 ...
随机推荐
- CTF-练习平台-Misc之 听首音乐
十九.听首音乐 用软件audacity打开后发现如下 上面那一行是可以看做摩斯电码,翻译过来是: ..... -... -.-. ----. ..--- ..... -.... ....- ----. ...
- 【MVC】View与Control之间数据传递
1. Controller向View传递数据 使用ViewData传递数据[弱类型,字典型ViewDataDictionary] ViewData[“Message_ViewData”] = “ He ...
- echar生成雷达图
function createRadarChart(indicatorData, personData) { var myChart = echarts.init(document.getElemen ...
- sublime 自动添加兼容前缀插件autoprefixer
安装插件autoprefixer步骤: 1.确保Node.js已经安装,未安装请 点击 这里>> 2.下载autoprefixer插件 https://github.com/sindres ...
- read()/fread()/mmap()执行效率对比
一. read()/fread()/mmap()执行效率对比 系统调用read.c: #include <sys/types.h> #include <sys/stat.h> ...
- stenciljs 学习三 组件生命周期
stenciljs 组件包含好多生命周期方法, will did load update unload 实现生命周期的方法比价简单类似 componentWillLoad ....,使用typescr ...
- shrink_to_fit
// string::shrink_to_fit#include <iostream>#include <string> int main (){ std::string st ...
- FastAdmin selectPage 前端传递查询条件
★夕狱-东莞 2018/2/2 16:19:33 selectpage 怎么在前端传递查询条件,看了下源码,好像有个custom,怎么用来的,比如我要下拉的时候,只显示id=1的数据 Karson-深 ...
- Angular 4 表单校验1
1.html <form [formGroup]="formModel" (submit)="submit()"> <div> 用户名: ...
- ionic使用常见问题(八)——PHP无法获取$http的post数据
一个简单的post请求 $http.post('do-submit.php',myData) .success(function(){ // some code }); 可是,用angularjs ...