链接: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. Java学习——面向对象【3】

    1. 继承  java的类是单继承(一个子类只能继承一个父类),不能多继承(多个父类):A继承自B,A也继承自C,可以多重继承,就是A继承自B,B继承自C(A->B->C), 所有的类都继 ...

  2. Confluence 6 查看你的许可证细节

    希望查看你的 Confluence 许可证: 进入  > 基本配置(General Configuration). 在左侧的面板中选择 许可证详细(License Details). 你的许可证 ...

  3. PDF如何设置书签,怎么在PDF上添加书签

    PDF文件现在作为我们使用最多的一种办公文件,当然我们在使用PDF文件的同时还会需要编辑PDF文件,在使用一个PDF文件页数比较多的时候就需要添加书签,不然每次使用的时候都需要从头开始查找是很麻烦又头 ...

  4. django的查看sql语句setting设置

    LOGGING = {     'version': 1,     'disable_existing_loggers': False,     'handlers': {         'cons ...

  5. CentOS安装jdk的三种方法

    方法一:手动解压JDK的压缩包,然后设置环境变量 方法二:用yum安装JDK,(全称为 Yellow dog Updater, Modified)是一个在Fedora和RedHat以及CentOS中的 ...

  6. ServerSocket实现超简单HTTP服务器

    1.相关知识简介 HTTP协议 HTTP是常用的应用层协议之一,是面向文本的协议.HTTP报文传输基于TCP协议,TCP协议包含头部与数据部分,而HTTP则是包含在TCP协议的数据部分,如下图 HTT ...

  7. linux基础练习题(1)

    Linux命令作业(关卡一) 练习题1 理解操作系统的作用,以及各种操作系统的不同 要求: 简述什么是OS 简述应用程序.硬件.OS的关系 列举出3种常见的操作系统 简述Ubuntu和Linux的关系 ...

  8. vue自定义指令directives使用及生命周期

    生命周期 bind:只调用一次,指令第一次绑定到元素时调用,用这个钩子函数可以定义一个绑定时执行一次的初始化动作. inserted:被绑定元素插入父节点时调用(父节点存在即可调用,不必存在于docu ...

  9. net-snmp 安装与trap调试

    https://sourceforge.net/projects/net-snmp/files/net-snmp/5.7.3/

  10. thinkphp5分页传参

    $name = input('get.searchKey/s'); if($name != ""){ $this->assign('searchKey', $name); $ ...