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. velocity 显示List和Map方法

    一.遍历个map类型 1.先看后台java程序Java代码     Map<String,String> paramValues=new HashMap<String, String ...

  2. Scala 深入浅出实战经典 第52讲:Scala中路径依赖代码实战详解

    王家林亲授<DT大数据梦工厂>大数据实战视频 Scala 深入浅出实战经典(1-64讲)完整视频.PPT.代码下载:百度云盘:http://pan.baidu.com/s/1c0noOt6 ...

  3. oracle密码错误验证延迟

    补充从10g升级到11g之后需要注意的几个密码方面问题: 1. 11g默认开始密码区分大小写,可以通过把参数设置为SEC_CASE_SENSITIVE_LOGON =FALSE 屏蔽 2. 11g密码 ...

  4. Eclipse shortcuts

    Editor Shortcut Description Alt + / Content assist. A great help for our coding. Ctrl + Shift + F Fo ...

  5. Workday为何迟迟不进入中国

    全球知名HRM SaaS厂商Workday在世界各地攻城拔寨,俨然是HR SaaS的代名词,更是HRM市场的领导品牌.但是却单单在中国市场悄无声息,除了为数不多的海尔海外.联想海外等规模客户和部分ro ...

  6. html5开发之viewport使用

    随着高端手机(Andriod,Iphone,Ipod,WinPhone等)的盛行,移动互联应用开发也越来越受到人们的重视,用html5开发移动应用是最好的选择.然而,每一款手机有不同的分辨率,不同屏幕 ...

  7. Jdbc如何从PostgreSql读取海量数据?PostgreSql源代码分析纪录

    前言: 最近做数据同步,需要从PostgreSql获取数据,发现一旦数据比较多,那么读取的速度非常慢,并且内存占用特别多&GC不掉. 代码样例: 为了方便讲解,下面写了事例代码,从b2c_or ...

  8. SSAS:菜鸟摸门

    官方:SSAS 多维模型 Analysis Services 多维解决方案使用多维数据集结构来分析多个维度之间的业务数据. 多维模式是 Analysis Services 的默认服务器模式. 它包括针 ...

  9. Xcode 安装插件手误选择了「Skip Bundle」后需要重新允许「Load Bundle」的解决方法

    在 Mac 终端输入命令: # 这里的7.1代表 Xcode 的版本号 defaults delete com.apple.dt.Xcode DVTPlugInManagerNonApplePlugI ...

  10. nginx 常用配置说明

    一.location 配置 1.1 语法规则: location [=|~|~*|^~] /uri/ { … }= 开头表示精确匹配^~ 开头表示uri以某个常规字符串开头,理解为匹配 url路径即可 ...