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/homework/q10167.htm

analyse:

由于A,B的范围在-500~500之间,所以直接枚举就可以了。

Time complexity: O(n*n*m)

Source code: 

//  Memory   Time
// 1347K 0MS
// by : Snarl_jsb
// 2014-10-24-20.52
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<climits>
#include<cmath>
#define N 1000010
#define LL long long
using namespace std;
struct node
{
int x,y;
};
node p[110];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
// freopen("C:\\Users\\ASUS\\Desktop\\cin.cpp","r",stdin);
// freopen("C:\\Users\\ASUS\\Desktop\\cout.cpp","w",stdout);
int n,i,j,k,x,y;
while(cin>>n,n)
{
n<<=1;
for(int i=0;i<n;++i)
{
cin>>x>>y;
p[i].x=x,p[i].y=y;
}
int cnt;
bool f=0;
for(i=-500;i<=500;++i)
{
for(j=-500;j<=500;++j)
{
cnt=0;
for(k=0;k<n;++k)
{
if(p[k].x*i+p[k].y*j>0) cnt++;
if(p[k].x*i+p[k].y*j==0) break;
}
if(cnt==n>>1&&k==n)
{
cout<<i<<" "<<j<<endl;
f=1;
break;
}
}
if(f) break;
}
}
return 0;
}

  

Brute Force --- UVA 10167: Birthday Cake的更多相关文章

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

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

  2. uva 10167 - Birthday Cake

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

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

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

  4. 小白日记46:kali渗透测试之Web渗透-SqlMap自动注入(四)-sqlmap参数详解- Enumeration,Brute force,UDF injection,File system,OS,Windows Registry,General,Miscellaneous

    sqlmap自动注入 Enumeration[数据枚举] --privileges -U username[CU 当前账号] -D dvwa -T users -C user --columns  [ ...

  5. nginx 1.3.9/1.4.0 x86 Brute Force Remote Exploit

    测试方法: 本站提供程序(方法)可能带有攻击性,仅供安全研究与教学之用,风险自负! #nginx 1.3.9/1.4.0 x86 brute force remote exploit # copyri ...

  6. SRM 582 Div II Level Three: ColorTheCells, Brute Force 算法

    题目来源:http://community.topcoder.com/stat?c=problem_statement&pm=12581 Burte Force 算法,求解了所有了情况,注意  ...

  7. Test SRM Level Three: LargestCircle, Brute Force

    题目来源:http://community.topcoder.com/stat?c=problem_statement&pm=3005&rd=5858 思路: 如果直接用Brute F ...

  8. 安全性测试入门:DVWA系列研究(一):Brute Force暴力破解攻击和防御

    写在篇头: 随着国内的互联网产业日臻成熟,软件质量的要求越来越高,对测试团队和测试工程师提出了种种新的挑战. 传统的行业现象是90%的测试工程师被堆积在基本的功能.系统.黑盒测试,但是随着软件测试整体 ...

  9. HDU 6215 Brute Force Sorting(模拟链表 思维)

    Brute Force Sorting Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Othe ...

随机推荐

  1. 【转】Log4net用法

    Log4net用法 http://www.cnblogs.com/hfliyi/archive/2012/05/20/2510783.html

  2. viewpager的简单使用,以及ValueAnimator的用法示例

    之前在网上看到一篇viewpager简单使用的例子程序,主要采用了上部标签button+中间指示作用的imageview+下部viewpager的结构,点击上部标签,或者滑动viewpager,均可以 ...

  3. Glide.centerCrop()第一次显示无效

    Glide.with(context)      .load(url)      .centerCrop()     /** fitCenter() */      .placeholder(R.mi ...

  4. 关于php的mysqlnd驱动

    1.什么是mysqlnd驱动? PHP手册上的描述: MySQL Native Driver is a replacement for the MySQL Client Library (libmys ...

  5. SQL语句 - 数据操作

    表中数据的变化牵一发而动全身,会同时导致到索引中数据的变化.因此如果查询语句不需要索引,就应该删除无用的索引以提高效率. 一.INSERT语句 1.基本插入语句 insert用于向表中输入数据,其具体 ...

  6. 转载好文:如何进行基于情境数据的个性化EDM数据营销

    根据Adobe和DMA(Direct Marketing Association)的<实时营销洞察报告> (Real-Time Marketing Insights Study),77%的 ...

  7. 树莓派 HC-SRO4超声波测距模块的使用

    先上个图 这个模块的针脚跟之前玩的那三个有所区别,除了VCC和GND两个针脚,还多了两个Trig和Echo针脚,分别是输出和输入,Trig我接的是20针脚,Echo是21 该模块的工作原理为,先向TR ...

  8. MVC学习中遇到问题

    1:无法连接到localdb数据库 解决方案:下载localdb安装软件 2:运行程序时提示数据库已存在,请更改连接名 解决方案:因为在两个不同的解决方案中使用了同样的连接字符串造成生成了同样的数据库 ...

  9. winform用户控件

    用途用户控件包含Time控件和一个lable控件,一个ToolStrip控件,每隔一秒显示一次时间     1. 生成用户控件   新建一个项目类型为用户控件   注意定义类名,此类名为以后工具箱中显 ...

  10. (转) 寄存器、RAM、ROM、Flash相关概念区别整理

    转自 http://m.blog.chinaunix.net/uid-30077524-id-5570244.html 文章对这几个东西讲得很清楚,值得收藏. 寄存器 寄存器是中央处理器内的组成部份. ...