思路:简单枚举



AC代码:

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std; int x[105], y[105]; int main() {
int A, B, N;
while(scanf("%d", &N), N) {
for(int i = 0; i < 2 * N; i++) {
scanf("%d %d", &x[i], &y[i]);
} int flag = 0;
for(A = -500; A <= 500 && !flag; A++) {
for(B = -500; B <= 500 && !flag; B++) {
if(A || B) {
int c1 = 0, c2 = 0;
for(int i = 0; i < 2 * N; i++) {
if(x[i] * A + y[i] * B > 0) c1 ++;
else if(x[i] * A + y[i] * B < 0) c2 ++;
if(c1 == c2 && c1 == N) {
printf("%d %d\n", A, B);
flag = 1;
}
}
}
}
}
}
return 0;
}

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. Brute Force --- UVA 10167: Birthday Cake

     Problem G. Birthday Cake  Problem's Link:http://uva.onlinejudge.org/index.php?option=com_onlinejudg ...

  3. uva 10167 - Birthday Cake

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

  4. uva 10976 Fractions Again(简单枚举)

    10976 Fractions Again It is easy to see that for every fraction in the form 1 k (k > 0), we can a ...

  5. UVA.12716 GCD XOR (暴力枚举 数论GCD)

    UVA.12716 GCD XOR (暴力枚举 数论GCD) 题意分析 题意比较简单,求[1,n]范围内的整数队a,b(a<=b)的个数,使得 gcd(a,b) = a XOR b. 前置技能 ...

  6. UVA 1508 - Equipment 状态压缩 枚举子集 dfs

    UVA 1508 - Equipment 状态压缩 枚举子集 dfs ACM 题目地址:option=com_onlinejudge&Itemid=8&category=457& ...

  7. Java练习 SDUT-1959_简单枚举类型——植物与颜色

    简单枚举类型--植物与颜色 Time Limit: 1000 ms Memory Limit: 65536 KiB Problem Description 请定义具有red, orange, yell ...

  8. UVA 725 UVA 10976 简单枚举

    UVA 725 题意:0~9十个数组成两个5位数(或0开头的四位数),要求两数之商等于输入的数据n.abcde/fghij=n. 思路:暴力枚举,枚举fghij的情况算出abcde判断是否符合题目条件 ...

  9. UVa 725 简单枚举+整数转换为字符串

    Division  Write a program that finds and displays all pairs of 5-digit numbers that between them use ...

随机推荐

  1. cmd 操作命令

    1)cd 操作文件目录的 cd path #进入path cd / #返回到当前盘符的根目录 cd .. #返回到上级目录 2)dir 显示当前目录 dir #显示当前目录下的文件夹 dir path ...

  2. 紫书 例题 10-8 UVa 1262 (暴力枚举)

    递归一遍遍历所有情况就ok了 #include<cstdio> #include<cstring> #define REP(i, a, b) for(int i = (a); ...

  3. Android 4.3 系统裁剪——删除不使用的app及添加自己app

    删除不使用的apk 系统自带的app位置是在/android4.3/packages/apps 以下是一些APP作用分析: | |– BasicSmsReceiver | |– Bluetooth ( ...

  4. WITH common_table_expression (Transact-SQL)

    https://docs.microsoft.com/en-us/sql/t-sql/queries/with-common-table-expression-transact-sql Specifi ...

  5. thinkphp5项目--企业单车网站(六)

    thinkphp5项目--企业单车网站(六) 项目地址 fry404006308/BicycleEnterpriseWebsite: Bicycle Enterprise Websitehttps:/ ...

  6. Servlet doPost方法同时上传图片和传递参数

    上传图片和传递参数 上传图片和文件属于enctype="multipart/form-data"  form中加入enctype="multipart/form-data ...

  7. 【基础篇】DatePickerDialog日期控件的基本使用(二) ——分别获取年、月、日、时、分

    项目步骤: 1.在Main.xml布局文件中定义对应的组件,Main.xml内容如下: <?xml version="1.0" encoding="utf-8&qu ...

  8. Redis的安装与启动(doc和本地客户端)

    官网 安装都是老生长谈了(这个也不错),这里推荐俩个文章看看把.:打开一个cmd窗口 使用cd命令切换目录到 C:\redis 运行 redis-server.exe redis.conf(安装的关键 ...

  9. 互联网金融研究组:P2P借贷平台:性质、风险与监管(上)

    互联网金融研究组(): P2P借贷平台:性质.风险与监管(上) 目 录 一.性质与合法性 1.  P2P网络借贷 1.1  概念重新界定 1.2  发展概况与特点 2.  延伸模式及其合法性浅析 2. ...

  10. 系统管理员的 SELinux 指南:这个大问题的 42 个答案

    安全.坚固.遵从性.策略是末世中系统管理员的四骑士.除了我们的日常任务之外 —— 监控.备份.实施.调优.更新等等 —— 我们还需要负责我们的系统安全.即使这些系统是第三方提供商告诉我们该禁用增强安全 ...