链接:https://www.nowcoder.com/acm/contest/163/A
来源:牛客网

题目描述

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 ≤ 1e4) 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(-1e9≤ xi,yi≤ 1e9),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

-->

示例1

输入

复制

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 第一次做题用到随机数,蒟蒻
用不用srand应该都差不多
题意是给你n个点 是否满足一条线上有m个点 m/n>=x,随机数枚举
 #include<bits/stdc++.h>
using namespace std; const int maxn = 1e4+;
struct Node
{
int x,y;
} node[maxn];
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int n;
double x;
int cnt = ;
int flag = ;
scanf("%d%lf",&n,&x);
for(int i=; i<n; i++)
{
scanf("%d%d",&node[i].x,&node[i].y);
}
srand(time());
for(int i=; i<; i++)
{
int a = rand()%n;
int b = rand()%n;
if(a == b)continue;
cnt = ;
for(int j=; j<n; j++)
{
if((node[a].x-node[j].x)*(node[b].y-node[j].y) == (node[b].x-node[j].x)*(node[a].y-node[j].y))
cnt++;
}
if(cnt >= x * n)
{
flag = ;
break;
}
}
if(flag)printf("Yes\n");
else printf("No\n");
}
}

Fruit Ninja(随机数rand())的更多相关文章

  1. Fruit Ninja(取随机数)

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

  2. 牛客 Fruit Ninja 2018 ACM 上海大都会赛 (随机化算法)

    题目链接:Fruit Ninja 比赛链接:2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 题目描述 Fruit Ninja is a juicy action game enjoyed ...

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

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

  4. SDUT 2416:Fruit Ninja II

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

  5. hdu 4000 Fruit Ninja 树状数组

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

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

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

  7. hdu 4620 Fruit Ninja Extreme

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

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

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

  9. hdu4620 Fruit Ninja Extreme

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

随机推荐

  1. js跳转页面(转)

    <span id="tiao">3</span><a href="javascript:countDown"></a& ...

  2. CSS学习——基础分类整理

        1. CSS     层叠样式表: Cascading Style Sheets,定义如何显示html元素 CSS规则: 选择器{属性: 值; 属性: 值;} CSS注释: /*在这里写注释说 ...

  3. leetcode(js)算法之914卡牌分组

    给定一副牌,每张牌上都写着一个整数. 此时,你需要选定一个数字 X,使我们可以将整副牌按下述规则分成 1 组或更多组: 每组都有 X 张牌. 组内所有的牌上都写着相同的整数. 仅当你可选的 X > ...

  4. nginx实战(三)之静态资源web服务(跨站访问)

    语法 虽然说浏览器禁止跨站访问以防(CSRF),但出于一些原因还是要进行跨站访问,服务端通过设置头信息Access-Control-Allow-Orign:xxxx,客户端收到后就会允许跨站访问了 实 ...

  5. angularjs 监听 文档click 事件

    项目 上遇到  innHTML  放入 一大段的html 内容 中带有 click 事件 如onclick="callInMethod("http://www.crm.bmcc.c ...

  6. sql查询条件为空的另类写法o( ̄▽ ̄)d

    简单描述:今天看老大提交的代码,发现了一个有意思的事情,一条sql中判断条件是空,老大的写法,让我眼前一亮.直接上代码 代码: <select id="getxxxs" re ...

  7. Web Penetration Testing w3af fierce

    1.启动wsaf工具,设置载入插件(攻击模型的插件),可以设置默认的攻击模型,也可以添加自己的plug. 2.在侦查的时候渗透邮箱需要知道,云行邮箱服务的托管服务器是什么类型,在之前的博客中我已近两提 ...

  8. Niagara workbench 介绍文档---翻译

    一. 发现在建立station的时候存在一些问题,所以对技术文档部分做一个详细的了解,在这之前对出现的问题总结一下 1.  在 Windows操作系统中Application Direction中可以 ...

  9. axure—日期函数

    日期函数 日期函数中实现倒计时的关键点:1)gettime()函数可以取到1970年1月1日的时间,我们用倒计时结束的时间减去当前时间就能得到倒计时需要循环显示的所有时间.2)此处的“d”是倒计时结束 ...

  10. jmeter 控制线程组执行顺序

    这个要配合全局变量.if和while来实现BeanShell取样器,全局变量:${__setProperty(newswitch,${switch1},)}if条件:"${__P(newsw ...