Birthday Cake
来源:互联网 发布:mysql语句笔试 编辑:程序博客网 时间:2024/06/05 17:08
Description
Problem G. Birthday Cake
Background
Lucy and Lily are twins. Today is their birthday. Mother buys a birthday cake for them.Now we put the cake onto a Descartes coordinate. Its center is at (0,0), and the cake's length of radius is 100.
There are 2N (N is a integer, 1<=N<=50) cherries on the cake. Mother wants to cut the cake into two halves with a knife (of course a beeline). The twins would like to be treated fairly, that means, the shape of the two halves must be the same (that means the beeline must go through the center of the cake) , and each half must have N cherrie(s). Can you help her?
Note: the coordinate of a cherry (x , y) are two integers. You must give the line as form two integers A,B(stands for Ax+By=0), each number in the range [-500,500]. Cherries are not allowed lying on the beeline. For each dataset there is at least one solution.
Input
The input file contains several scenarios. Each of them consists of 2 parts: The first part consists of a line with a number N, the second part consists of 2N lines, each line has two number, meaning (x,y) .There is only one space between two border numbers. The input file is ended with N=0.Output
For each scenario, print a line containing two numbers A and B. There should be a space between them. If there are many solutions, you can only print one of them.Sample Input
2-20 20-30 20-10 -5010 -50
Sample Output
0 1
题目看那了下,还好.没什么感觉
#include<iostream>#include<stdio.h>#include<cmath>using namespace std;struct note{int x,y;};int main(){int n,d,i=0,j,k;note xun[500],gei[550];while(scanf("%d",&n)&&n){for( i=0;i<2*n;i++){scanf("%d%d",&gei[i].x,&gei[i].y);}int x=1;for( i=-500;i<510;i++){int num=0; for( j=-500;j<500;j++){int num=0; if(i==0&&j==0)continue; for( k=0;k<2*n;k++) { if((i*gei[k].x+j*gei[k].y)>0)num++; if((i*gei[k].x+j*gei[k].y)==0)break; } if(k==2*n&&num==n) { x=0; break; } }if(x==0)break;}printf("%d %d\n",i,j); }}
- Birthday Cake
- Birthday Cake
- Birthday Cake
- Birthday Cake
- Birthday Cake
- UVa 10167 - Birthday Cake
- 10167--Birthday Cake
- UVa:10167-birthday cake
- poj 2515 Birthday Cake
- UVA 10167 Birthday Cake
- uva 10167 - Birthday Cake
- 10167 - Birthday Cake
- UVa 10167 Birthday Cake
- UVaOJ 10167 - Birthday Cake
- uva 10167 - Birthday Cake
- UVa 10167 Birthday Cake
- uva 10167 - Birthday Cake
- UVa 10167 - Birthday Cake
- hdu 1081 To The Max
- JSP(6):网站框架的改进mv模式
- 谷歌和其他搜索引擎找到各种移动应用
- c#代码项目风格要求
- 周报(第二周)
- Birthday Cake
- 分类的IP地址(一)
- 看 【罗辑思维】番外篇《五问互联网》有感
- 移动应用和应用商店的seo优化有两个方面
- Fire Net HDU
- javax.el.PropertyNotFoundException: Property 'name' not found on type java.lang.String
- 心形函数-封心
- 一个应用程序将有两个页面优化
- 获取html表单元素小结