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 ≥ 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的更多相关文章
- 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 ...
随机推荐
- UIButton 左对齐 省略号最右边
//左对齐 [_btn setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft]; //省略号靠右侧 _btn.ti ...
- C#入门(3)
C#入门(3) Delegates, Events, Lambda Expressions 最早的windows是使用c风格的函数指针来进行callback的,但是这样仅仅传递了一个内存中的地址,无法 ...
- 程序windows上可以上传附件,部署到 linux服务器后出现 “上传目录 不可写” 怎么解决?
这样的问题一般都是linux 下文件读写权限引起的,用 shell 命名到上传附件的目录(如 cd /data/www/project/upload/),然后执行 shell 文件权限设置: 例如 ...
- Resize a UIImage the right way
When deadlines loom, even skilled and experienced programmers can get a little sloppy. The pressure ...
- Python-OpenCV:cv2.imread(),cv2.imshow(),cv2.imwrite()
为什么使用Python-OpenCV? 虽然python 很强大,而且也有自己的图像处理库PIL,但是相对于OpenCV 来讲,它还是弱小很多.跟很多开源软件一样OpenCV 也提供了完善的pytho ...
- 转 在Qt中用QAxObject来操作Excel
最近写程序中需要将数据输出保存到Excel文件中.翻看<C++ GUI Programming with Qt 4>(Second Edition)发现可以在Qt中运用ActiveX控件, ...
- MFC:AfxParseURL
BOOL AFXAPI AfxParseURL( LPCTSTR pstrURL, DWORD& dwServiceType, CString& strServ ...
- hibernate4整合spring3.1的过程中的异常问题
(1)hibernate4整合spring3.1的过程中,发现了java.lang.NoClassDefFoundError: Lorg/hibernate/cache/CacheProvider异常 ...
- POI读word docx 07 文件的两种方法
POI在读写word docx文件时是通过xwpf模块来进行的,其核心是XWPFDocument.一个XWPFDocument代表一个docx文档,其可以用来读docx文档,也可以用来写docx文档. ...
- shell脚本,awk合并一列的问题。
文件 file2内容如下:0 qwert1 asdfghjk2 asdjkl2 zxcvbn3 dfghjkll4 222224 tyuiop4 bnm 让第一列相等的合并成一行,不要第一列,也就是变 ...