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.

输入描述:

  1. 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.
  1. 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.
  1. 输出描述:
  1. For each test case, output "Yes" if there are at least one EXCELLENT touch. Otherwise, output "No".

输入

  1. 2
  2. 5 0.6
  3. -1 -1
  4. 20 1
  5. 1 20
  6. 5 5
  7. 9 9
  8. 5 0.5
  9. -1 -1
  10. 20 1
  11. 1 20
  12. 2 5
  13. 9 9

输出

  1. Yes
  2. No

  1. 题目:n个点,问是否至少有n*x个点在一条直线上。
    对于极限数据n=10000x=0.1的情况,分析发现我们若是随机选取一个点,选到这条直线上的点的概率是1/10,反之选不到的概率就是9/10
    那这样我们选取n次,选不到的概率就是(9/10)的n次方。当n较大时,这个概率就足够低,可以让我们通过这个题。
  1. #include <bits/stdc++.h>
  2. #define N 1000000007
  3. using namespace std;
  4. long double check[];
  5. int x[],y[];
  6.  
  7. int main()
  8. {
  9. int t;
  10. scanf("%d",&t);
  11. while(t--)
  12. {
  13. int n,c1=,up,ans=;
  14. double xx;
  15. scanf("%d %lf",&n,&xx);
  16. up=ceil(xx*1.0*n);
  17.  
  18. for(int i=; i<=n; i++)scanf("%d %d",&x[i],&y[i]);
  19.  
  20. for(int i=; i<=min(,n-up+); i++)
  21. {
  22. c1=;
  23. for(int j=; j<=n; j++)
  24. if(i!=j)
  25. {
  26. if(x[j]!=x[i])check[c1++]=(y[j]-y[i])*1.0/(x[j]-x[i]);
  27. else
  28. check[c1++]=N;
  29. }
  30. sort(check,check+c1);
  31.  
  32. int tot=;
  33. check[c1]=N+;
  34. for(int i=; i<=c1; i++)
  35. {
  36. if(check[i]!=check[i-])
  37. {
  38. ans=max(ans,tot+);
  39. tot=;
  40. }
  41. else
  42. tot++;
  43. }
  44.  
  45. if(ans>=up)
  46. {
  47. break;
  48. }
  49.  
  50. }
  51.  
  52. if(ans>=up)
  53. {
  54. printf("Yes\n");
  55.  
  56. }
  57. else
  58. {
  59. printf("No\n");
  60.  
  61. }
  62.  
  63. }
  64. return ;
  65. }

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. 洛谷 P2922 [USACO08DEC]秘密消息Secret Message

    题目描述 Bessie is leading the cows in an attempt to escape! To do this, the cows are sending secret bin ...

  2. (十)maven之排除冲突jar包

    排除冲突jar包 jar包冲突 <dependencies> <dependency> <groupId>org.springframework</group ...

  3. KissXML的XPath选取问题

    XMPPFramework用的XML解析库还是大神自己写的KissXML,有些人生下来就是让人仰望的,哎. 进入主题,如下一段XML: <paramsxmlns="namespace& ...

  4. 想转行做web前端工程师,必学这5大技能!知道是那些吗?

    web前端工程师是近几年才发展出来的新兴职业,也是目前火爆且高薪的职业. 大需求的市场环境下,出现了越来越多的人群转行做web前端工程师,如设计师.后台程序员.网虫.大学其他专业.策划.编辑等等. 要 ...

  5. Schur 三角化定理的推论

    将学习到什么 从 Schur 的酉三角化定理可以收获一批结果,在这一部分介绍重要的几个.   迹与行列式 相似矩阵具有相同的特征多项式, 从特征多项式一节中, 我们又知道,相似矩阵的迹以及行列式都是相 ...

  6. Ubuntu12.04安装Chrome浏览器,并添加到左侧的启动栏

    在google官网下载google chrome deb包,有32位和64位之分: 怎么判断系统是32位还是64位的,可以用以下代码: ; int *p = &a; printf(" ...

  7. PAT (Basic Level) Practise (中文)- 1024. 科学计数法 (20)

    PAT (Basic Level) Practise (中文)- 1024. 科学计数法 (20) http://www.patest.cn/contests/pat-b-practise/1024 ...

  8. shelll脚本,常见的脚本题目。

    [root@localhost wyb]# cat 2quan.sh #!/bin/bash #写一个脚本,先要求输入用户名,然后让他输入一个数字,输的如果是数字给输出yes,不是数字,输出no #然 ...

  9. 智能指针之 weak_ptr

    1. weak_ptr 介绍 std::weak_ptr 是一种智能指针,它对被 std::shared_ptr 管理的对象存在非拥有性("弱")引用.在访问所引用的对象指针前必须 ...

  10. (55)zabbix模板嵌套

    在zabbix使用过程中,在某些情况下,一个host需要link多个模板.这么做显得比较麻烦,很容易忘记到底要link哪些模板,我想link一个模板就达成这个目标,行不行?然没问题,zabbix模板内 ...