UVA - 10167 - Birthday Cake (简单枚举)
思路:简单枚举
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 (简单枚举)的更多相关文章
- 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 10167 - Birthday Cake
题解:由于解太多,随机抓 A.B, 只要有符合就行了: (首先,Ax+By=0必须表示直线,即A.B不能同时为0:另外,要注意到直线不能过输入中的2N个点:检测点在直线的哪一侧,只需要简单的线性规划的 ...
- 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 ...
- UVA.12716 GCD XOR (暴力枚举 数论GCD)
UVA.12716 GCD XOR (暴力枚举 数论GCD) 题意分析 题意比较简单,求[1,n]范围内的整数队a,b(a<=b)的个数,使得 gcd(a,b) = a XOR b. 前置技能 ...
- UVA 1508 - Equipment 状态压缩 枚举子集 dfs
UVA 1508 - Equipment 状态压缩 枚举子集 dfs ACM 题目地址:option=com_onlinejudge&Itemid=8&category=457& ...
- Java练习 SDUT-1959_简单枚举类型——植物与颜色
简单枚举类型--植物与颜色 Time Limit: 1000 ms Memory Limit: 65536 KiB Problem Description 请定义具有red, orange, yell ...
- UVA 725 UVA 10976 简单枚举
UVA 725 题意:0~9十个数组成两个5位数(或0开头的四位数),要求两数之商等于输入的数据n.abcde/fghij=n. 思路:暴力枚举,枚举fghij的情况算出abcde判断是否符合题目条件 ...
- UVa 725 简单枚举+整数转换为字符串
Division Write a program that finds and displays all pairs of 5-digit numbers that between them use ...
随机推荐
- USART
串口通信是一种设备间非常常用的串行通行方式,其简单便捷,大部分电子设备都支持. 一.物理层 常用RS-232标准,主要规定了信号的用途.通信接口以及信号的电平标准. “DB9接口”之间通过串口信号线 ...
- 国庆 day 6 下午
1.数组异或 (xorarray.pas/c/cpp) (xorarray.in/out) 时间限制:2s/空间限制:256M [题目描述] xor——异或,和 and 与or 一样,是一种重要的逻辑 ...
- ArcGIS Engine获得要素的中心点坐标
IPoint centerPoint =new PointClass();//获得要素的中心点 IArea pArea = pFeature.Shape as IArea; pArea.QueryCe ...
- [Python] Statistical analysis of time series
Global Statistics: Common seen methods as such 1. Mean 2. Median 3. Standard deviation: the larger ...
- Oracle拾遗
这次学习Oracle视频.还是学到了不少东西的. 首先,这是一次系统的学习.对自己的知识体系是一次查漏补缺,曾经仅仅是简单的会用,如今看到出的问题,非常easy就能够想到是哪一部分出了问题.尤其是如今 ...
- Oracle EBS发放销售订单
模拟发放销售订单界面进行发放操作 PROCEDURE insert_row(x_batch_id OUT NUMBER) IS l_autopack_flag VARCHAR2(1 ); l_a ...
- AFNetworking框架的使用
#import "ViewController.h" #import "AFNetworking.h" @interface ViewController () ...
- VS链接数据库
可以用VS链接数据库,并进行数据库操作.前提是安装了Sqlserver,活着连接线上的数据库服务器.
- hdoj--5333--Dancing Stars on Me(水题)
Dancing Stars on Me Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Ot ...
- Sub Thread to update main Thread (UI)
Sub Thread to update main Thread (UI) main Thread : A has Hander.HandleMessage() to process the & ...