给出n个点,问你有没有可能存在一条直线,这n个点中存在百分号p以上点在这条直线上。

两个点确定一条直线,所以可以随机枚举两个点,然后用这条直线去判断其他的点是不是在这条直线上,如果在这个直线上的点超过%p,那么就说明找到了一种情况

#include<map>
#include<set>
#include<ctime>
#include<cmath>
#include<stack>
#include<queue>
#include<string>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define lowbit(x) (x & (-x))
#define INOPEM freopen("in.txt", "r", stdin)
#define OUTOPEN freopen("out.txt", "w", stdout) typedef unsigned long long int ull;
typedef long long int ll;
const double pi = 4.0*atan(1.0);
const int inf = 0x3f3f3f3f;
const int maxn = 1e5+;
const int maxm = ;
const int mod = 1e9+;
using namespace std; int n, m;
int T, tol;
struct Node {
ll x, y;
};
Node node[maxn]; int check(int i, int j, int k) {
ll ans1 = (node[i].x - node[j].x) * (node[i].y - node[k].y);
ll ans2 = (node[i].x - node[k].x) * (node[i].y - node[j].y);
if(ans1 == ans2) return ;
else return ;
} //x1-x2 x1-x3
//y1-y2 y1-y3 int main() {
srand(time());
while(~scanf("%d%d", &n, &m)) {
memset(node, , sizeof node);
for(int i=; i<n; i++) scanf("%lld%lld", &node[i].x, &node[i].y);
if(n <= ) {
printf("possible\n");
continue;
}
int ans = n*m;
bool flag = false;
for(int T=; T<=; T++) {
int sum = ;
int x = rand() % n;
int y = rand() % n;
while(x == y) y = rand() % n;
for(int i=; i<n; i++) {
if(i == x || i == y) continue;
sum += check(x, y, i);
if(sum * >= ans) {
flag = true;
break;
}
}
if(flag) break;
}
printf("%s\n", flag ? "possible" : "impossible");
}
return ;
}

Finding Lines UVALive - 6955(随机)的更多相关文章

  1. 随机算法 - HNU 13348 Finding Lines

    Finding Lines Problem's Link: http://acm.hnu.cn/online/?action=problem&type=show&id=13348&am ...

  2. Finding Lines

    Finding Lines 题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8& ...

  3. UVALive - 6955 Finding Lines 随机算法

    题目链接: http://acm.hust.edu.cn/vjudge/contest/126968#problem/F 题意 给你n个点,问是否有>=p/100*n个点共线(p>=20& ...

  4. UVALive 6955 Finding Lines(随机化优化)题解

    题意:问你是否有一条直线满足这条直线上的点个数与总个数之比不小于p 思路:解法太暴力了,直接随机取两个数,如果能满足条件就输出可以,否则不行.证明一下为什么可以随机化,题目给出可能有P >=20 ...

  5. Educational Codeforces Round 41 (Rated for Div. 2) D. Pair Of Lines (几何,随机)

    D. Pair Of Lines time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...

  6. java随机生成验证码

    package com.yuyuchen.util; import java.awt.Color; import java.awt.Font; import java.awt.Graphics; im ...

  7. Gym101482 NWERC 2014(队内训练第4场)

    -----------------------前面的两场感觉质量不高,就没写题解----------------------------- A .Around the Track pro:给定内多边形 ...

  8. Gym 101482 题解

    B:Biking Duck 题意:现在有一个人要从(x1,y1)点走到(x2,y2)点, 现在走路的速度为v. 还有骑自行车的速度v2,自行车要从某个自行车站到另一个自行车站,现在我们可以视地图的边界 ...

  9. ImageUtil(验证码数据生成工具类)

    登录界面时,常常会使用到验证码图片生成,程序如下: package util; import java.awt.Color; import java.awt.Font; import java.awt ...

随机推荐

  1. oracle小记:dba_data_files

    今天给表空间扩展的时候,使用了dba_data_files进行查询.查阅了网上的资料. 该系统系统中含有以下字段 每个字段的含义如下:

  2. mysql5.7 的 user表的密码字段从 password 变成了 authentication_string

    来源: http://www.zhimengzhe.com/shujuku/other/267631.html 感觉还是挺坑的 自己没了解清楚 就动手 转帖一下 mark 一下. 1.首先停止正在运行 ...

  3. "errcode":40163,"errmsg":"code been used...报错,做PC微信登录时出现code been used...报错问题

    这是一个坑,一个巨坑,一个恶心的坑 出现这个问题的大概意思就是微信回调了两次登录接口,code使用了两次,而在微信官方文档上写着code只能用一次,用来获取access_token,但我TM看着就糊涂 ...

  4. CSS3 transform-style 属性

    语法     transform-style: flat | preserve-3d   语法项目 说明  初始值         flat  适用于         块元素和行内元素 可否继承    ...

  5. BPM与OA的区别

    近年来,随着计算机技术的发展和互联网时代的到来,我们已经进入了信息时代,也称为数字化时代,在这数字化的时代里,企业的经营管理都受到了极大的挑战.从上世纪90年代起至今,企业的信息化工作开展的如火如荼, ...

  6. SpringBoot 4.SpringBoot 整合 devtools 实现热部署

    一.添加 devtools 依赖 <!-- Spring boot 热部署 : 此热部署会遇到 java.lang.ClassCastException 异常 --> <!-- op ...

  7. vue & iview

    vue & iview ui components https://codepen.io/webgeeker/pen/EJmQxQ https://www.iviewui.com/docs/g ...

  8. github---无命令可视化界面操作

    最近工作需要,研究了一下git,这个东西挺实用,给我的感觉并不是那么简单使用,我认为还可以再深入的研究一下,挺好玩的~ 说一下我的学习路线: 1.先看的廖老师的博客:https://www.liaox ...

  9. 文件操作 chardet使用

    #_*_coding:utf-8_*_ import chardet #f = open(file="兼职白领学生空姐模特护士联系方式.txt", mode="rb&qu ...

  10. Spring boot多线程

    1.配置线程配置类 package test; import java.util.concurrent.Executor; import org.springframework.aop.interce ...