链接: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");
}
}

最新文章

  1. Perl爬取江西失信执行
  2. 1014 C语言文法
  3. Java获取本地IP地址
  4. linux怎么运行.SH文件
  5. JavaScript 高级程序设计 01-基本概念
  6. 2016年11月1日——jQuery源码学习笔记
  7. python基础之数据类型/字符串/元组/列表/字典
  8. android-蓝牙通信
  9. 【新版】Android技术博客精华汇总
  10. 基于python的统计公报关键数据爬取 update
  11. Redux thunk中间件
  12. git常用命令总结(资源来自廖雪峰)
  13. Angular 双向数据绑定
  14. 做到让DBCP连接池不超时
  15. django学习~models之查询
  16. learning ddr Electrical Characteristics and AC Timing
  17. ios 让textView被键盘挡住上移
  18. 生成验证码程序C#
  19. Jmeter 接口测试间的引用
  20. 一个用户管理的ci框架的小demo--转载

热门文章

  1. 分享一份非常强势的Android面试题
  2. oracle 在C# 中调用oracle的数据库时,出现引用库和当前客户端不兼容的问题解决方案
  3. Confluence 6 重要缓存和监控
  4. kali linux revealed mastering the penetration testing distribution
  5. vue 中动态绑定class 和 style的方法
  6. Java手动释放对象
  7. vetur插件提示 [vue-language-server] Elements in iteration expect to have &#39;v-bind:key&#39; directives错误的解决办法
  8. excel vba获取拼音
  9. 解决AS gradle下载同步卡慢的问题
  10. Windows10系统运行bat文件 一闪而过 解决