链接: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. swift 实践- 05 -- UITextField

    import UIKit class ViewController: UIViewController ,UITextFieldDelegate{ // 文本框的创建, 有如下几个样式: // UIT ...

  2. Confluence 6 数据库整合的方法 1:基本流程

    步骤 1:对你的插件进行记录 对你近期在 Confluence 中安装和启用的插件进行记录,这你可以在后期对插件进行重新安装或者调整.针对你安装的插件,你需要记录下面的一些内容: 插件名称 版本号 启 ...

  3. java多线程快速入门(十九)

    如何停止线程 1.使用stop方法强行终止线程(这个方法不推荐使用,可能会出现业务操作未执行完,线程中断了) package com.cppdy; class MyThread15 extends T ...

  4. android入门小结一

    一 Android入门基础:从这里开始 gradle介绍: Android Studio使用Gradle 编译运行Android工程. 工程的每个模块以及整个工程都有一个build.gradle文件. ...

  5. laravel 获取当前月,当前星期,当天起始时间方法

    获取当前月起始时间: 1. $time=time(); $start=date('Y-m-01',$time);//获取指定月份的第一天 $end=date('Y-m-t',$time); //获取指 ...

  6. Niagara物联网框架机制一(笔记)

    一.介绍: Niagara是Tridium公司研发的设计用于解决设备连接应的软件框架平台技术,应用框架是一个软件工程中的概念,不同于普通的软件,它是用于实现某应用领域通用完备功能的底层服务,使用这种框 ...

  7. cf1025c 思维题

    /* bwwwbwwbw wwbwwwbwb 不管从哪里断开翻转.翻转后的串再整体翻转一定是2s的子串 */ #include<bits/stdc++.h> using namespace ...

  8. hdu4276 依赖背包

    网上题解都是用spfa求1-n路径的,但其实dfs一次就可以了.. #include <iostream> #include <cstdio> #include <str ...

  9. C和Java判断一个数字是否为素数

    C: /* 素数: 素数又称质数.所谓素数是指除了 1 和它本身以外,不能被任何整数整除的数,例如17就是素数,因为它不能被 2~16 的任一整数整除. */ # include <stdio. ...

  10. Python老男孩

    1.可以自己编写模块,但注意:如果想要调用该模块,需要将该模块放到site-packages目录下,或将该模块放在执行程序的路径下. 2.pyc文件是什么? 集合: set 集合可以去重:做交集.并集 ...