Fruit Ninja

时间限制:C/C++ 5秒,其他语言10秒

空间限制:C/C++ 262144K,其他语言524288K
64bit IO Format: %lld

题目描述

Fruit Ninja is a juicy action game enjoyed by millions of players around the world, with squishy,
splat and satisfying fruit carnage! Become the ultimate bringer of sweet, tasty destruction with every slash.
Fruit Ninja is a very popular game on cell phones where people can enjoy cutting the fruit by touching the screen.
In this problem, the screen is rectangular, and all the fruits can be considered as a point. A touch is a straight line cutting
thought the whole screen, all the fruits in the line will be cut.
A touch is EXCELLENT if ≥ x, (N is total number of fruits in the screen, M is the number of fruits that cut by the touch, x is a real number.)
Now you are given N fruits position in the screen, you want to know if exist a EXCELLENT touch.

输入描述:

The first line of the input is T(1≤ T ≤ 100), which stands for the number of test cases you need to solve.
The first line of each case contains an integer N (1 ≤ N ≤ 10000) and a real number x (0 < x < 1), as mentioned above.
The real number will have only 1 digit after the decimal point.
The next N lines, each lines contains two integers xi and yi(-1000000000<=xi,yi<=1000000000),
denotes the coordinates of a fruit.
输出描述:
For each test case, output "Yes" if there are at least one EXCELLENT touch. Otherwise, output "No".

输入

2
5 0.6
-1 -1
20 1
1 20
5 5
9 9
5 0.5
-1 -1
20 1
1 20
2 5
9 9

输出

Yes
No

题目:n个点,问是否至少有n*x个点在一条直线上。
对于极限数据n=10000,x=0.1的情况,分析发现我们若是随机选取一个点,选到这条直线上的点的概率是1/10,反之选不到的概率就是9/10。
那这样我们选取n次,选不到的概率就是(9/10)的n次方。当n较大时,这个概率就足够低,可以让我们通过这个题。
#include <bits/stdc++.h>
#define N 1000000007
using namespace std;
long double check[];
int x[],y[]; int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int n,c1=,up,ans=;
double xx;
scanf("%d %lf",&n,&xx);
up=ceil(xx*1.0*n); for(int i=; i<=n; i++)scanf("%d %d",&x[i],&y[i]); for(int i=; i<=min(,n-up+); i++)
{
c1=;
for(int j=; j<=n; j++)
if(i!=j)
{
if(x[j]!=x[i])check[c1++]=(y[j]-y[i])*1.0/(x[j]-x[i]);
else
check[c1++]=N;
}
sort(check,check+c1); int tot=;
check[c1]=N+;
for(int i=; i<=c1; i++)
{
if(check[i]!=check[i-])
{
ans=max(ans,tot+);
tot=;
}
else
tot++;
} if(ans>=up)
{
break;
} } if(ans>=up)
{
printf("Yes\n"); }
else
{
printf("No\n"); } }
return ;
}

Fruit Ninja的更多相关文章

  1. sdut 2416:Fruit Ninja II(第三届山东省省赛原题,数学题)

    Fruit Ninja II Time Limit: 5000MS Memory limit: 65536K 题目描述 Have you ever played a popular game name ...

  2. SDUT 2416:Fruit Ninja II

    Fruit Ninja II Time Limit: 5000MS Memory limit: 65536K 题目描述 Have you ever played a popular game name ...

  3. hdu 4000 Fruit Ninja 树状数组

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4000 Recently, dobby is addicted in the Fruit Ninja. ...

  4. Sdut 2416 Fruit Ninja II(山东省第三届ACM省赛 J 题)(解析几何)

    Time Limit: 5000MS Memory limit: 65536K 题目描述 Haveyou ever played a popular game named "Fruit Ni ...

  5. hdu 4620 Fruit Ninja Extreme

    Fruit Ninja Extreme Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Othe ...

  6. Fruit Ninja(树状数组+思维)

    Fruit Ninja Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  7. hdu4620 Fruit Ninja Extreme

    Fruit Ninja Extreme Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...

  8. Fruit Ninja(随机数rand())

    链接:https://www.nowcoder.com/acm/contest/163/A来源:牛客网 题目描述 Fruit Ninja is a juicy action game enjoyed ...

  9. Fruit Ninja(取随机数)

    链接:https://www.nowcoder.com/acm/contest/163/A来源:牛客网 时间限制:C/C++ 5秒,其他语言10秒 空间限制:C/C++ 262144K,其他语言524 ...

随机推荐

  1. jQuery中ready方法的实现

    https://blog.csdn.net/major_zhang/article/details/80146674 先普及一下jquery.ready()和window.onload,window. ...

  2. 利用python进行数据分析1_numpy的基本操作,建模基础

    import numpy as np # 生成指定维度的随机多维数据 data=np.random.rand(2,3) print(data) print(type(data)) 结果: [[0.11 ...

  3. js parse_url 引发的

    原文链接:https://www.w3.org/TR/2011/WD-html5-20110525/origin-0.html 这里只是做下记录: 5.3 Origin — HTML5 li, dd ...

  4. jQuery中Ajax事件beforesend及各参数含义

    Ajax会触发很多事件. 有两种事件,一种是局部事件,一种是全局事件: 局部事件:通过$.ajax来调用并且分配. $.ajax({ beforeSend: function(){ // Handle ...

  5. Respond.js-----20150415

    Respond.js让IE6-8支持CSS3 Media Query. Bootstrap里面就引入了这个js文件,从名字看出来是自适应的兼容.打开IE看了一下,效果挺好的,自适应的效果挺好的.Res ...

  6. 使用 ss 命令查看连接信息

    作用:打印主机socket连接信息,netstate可以做的它都可以做,比netstate 更灵活,而且由于ss使用 tcp_diag 内核模块,所以速度更快. 用法: ss [ OPTIONS ] ...

  7. java.sql.date 插入数据库没有时分秒

    java.sql.date 插入数据库没有时分秒 把java中实体类的sql.date类型改成java.sql.Timestamp类型即可 util.date 转 Timestamp: java.sq ...

  8. java 比较String StringBuffer StringBuilder

    String 字符串常量StringBuffer 字符串变量(线程安全)StringBuilder 字符串变量(非线程安全) 简要的说, String 类型和 StringBuffer 类型的主要性能 ...

  9. 对freescale的mfgtool的ucl2.xml的理解

    转载于此:http://blog.csdn.net/bugouyonggan/article/details/8664898 对于Freescale MFG编程工具控制文件ucl2.xml的分析 为了 ...

  10. LeetCode(104) Maximum Depth of Binary Tree

    题目 Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the l ...