Fruit Ninja
Fruit Ninja
时间限制:C/C++ 5秒,其他语言10秒
64bit IO Format: %lld
题目描述
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
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的更多相关文章
- sdut 2416:Fruit Ninja II(第三届山东省省赛原题,数学题)
Fruit Ninja II Time Limit: 5000MS Memory limit: 65536K 题目描述 Have you ever played a popular game name ...
- SDUT 2416:Fruit Ninja II
Fruit Ninja II Time Limit: 5000MS Memory limit: 65536K 题目描述 Have you ever played a popular game name ...
- hdu 4000 Fruit Ninja 树状数组
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4000 Recently, dobby is addicted in the Fruit Ninja. ...
- Sdut 2416 Fruit Ninja II(山东省第三届ACM省赛 J 题)(解析几何)
Time Limit: 5000MS Memory limit: 65536K 题目描述 Haveyou ever played a popular game named "Fruit Ni ...
- hdu 4620 Fruit Ninja Extreme
Fruit Ninja Extreme Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Othe ...
- Fruit Ninja(树状数组+思维)
Fruit Ninja Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total ...
- hdu4620 Fruit Ninja Extreme
Fruit Ninja Extreme Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- Fruit Ninja(随机数rand())
链接:https://www.nowcoder.com/acm/contest/163/A来源:牛客网 题目描述 Fruit Ninja is a juicy action game enjoyed ...
- Fruit Ninja(取随机数)
链接:https://www.nowcoder.com/acm/contest/163/A来源:牛客网 时间限制:C/C++ 5秒,其他语言10秒 空间限制:C/C++ 262144K,其他语言524 ...
随机推荐
- 线段树成段更新模板POJ3468 zkw以及lazy思想
别人树状数组跑几百毫秒 我跑 2500多 #include<cstdio> #include<map> //#include<bits/stdc++.h> #inc ...
- JAVA 配置
JAVA 版本为jdk-7u25-windows-x64 Java 下载地址为: .CLASSPATH .;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.j ...
- urlrrtrieve()实例_下载微博短视频
1.确定目标 在微博页面找一想要下载的短视频,通过审查元素找到视频的url. 如://f.us.sinaimg.cn/00150tBNlx07l0qjoSJi01040201m7z90k010.mp4 ...
- ucosii(2.89)semaphore 应用要点
semaphore 的作用:1,允许一个任务与其他任务(中断)同步.2,取得共享资源使用权.3,标志事件的发生.
- [已解决]gitee初次使用git clone报错
本文描述的错误按实际出现先后顺序排列,并且附上一些其他可能会出现的问题 错误1: JZKJ@DESKTOP-I7Q9QJ4 MINGW64 ~ $ git clone https://gitee.co ...
- Java获取字符串里面的重复字符
public static void main(String[] args) { String word="天地玄黄宇宙洪荒" + "日月盈昃辰宿列张" + & ...
- Fisherfaces 算法的具体实现源码
/* * Copyright (c) 2011. Philipp Wagner <bytefish[at]gmx[dot]de>. * Released to public domain ...
- CSS实现跳动的桃心
又来刷题--CSS动画实现跳动的桃心,从哪里跌倒就从哪里爬起来,哈哈哈~ 分析:首先,得画出一个桃心,然后再用动画效果让它跳起来(关于动画,实在是弱项啊~~~,得补补了). 第一步:画桃心,思路是一个 ...
- 关于JS的继承总结
最近都在巩固JS的基础知识,今天组要看的是有关继承方面的,每次看都会加深自己的理解呢 1.借助构造函数实现继承 原理:在子类中改变父类this的指向 function Parent1() { this ...
- 《零基础入门学习Python》【第一版】视频课后答案第006讲
python中被看作假:FALSE none 0 ‘ ’ " " ( ) [ ] { },其他一切都被解释为真 测试题答案: 0.Python 的 floor 除法现在使用 ...