codeforces 850 A

A. Five Dimensional Points

introduction

n个点中,是否存在一个点,与另外任意两个点连成的向量,为锐角

method

首先在2维的空间中,要让角不为锐角,最多只能存在5个点(四个向量) 。鸽巢原理。在k维空间中,最多只能存在2k+1个节点。k=5时,最多只能存在11个节点。所以:

  • 输出0,如果节点数大于11
  • 枚举,如果节点数小于等于10

tips

  1. 成角的向量不能随意交换向量的两个端点
  2. 节点数=向量数+ 1
  3. 鸽巢原理是非常有用

reference

http://codeforces.com/blog/entry/54317
https://blog.csdn.net/Fusheng_Yizhao/article/details/78557741
鸽笼原理 谢聪智

code

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<istream>
#include<ostream>
#define DEBUG(x) cout<<#x<<" = "<<x<<endl
#define pi acos(-1)
using namespace std;
const int MAXN=1e3+10;
struct point{int a[5];point(){memset(a,0,sizeof(a));}friend istream & operator>>(istream &in,point &p){for(int i=0;i<5 ;i++ ){in>>p.a[i];}return in;}friend ostream &operator<<(ostream &out,const point &p){for(int i=0;i<5 ;i++ ){out<<p.a[i]<<" ";}return out;}
};
typedef point vec;
inline vec mkvec(point &p1,point &p2)
{vec v;for(int i=0;i<5 ;i++ ){v.a[i]=p2.a[i]-p1.a[i];}return v;
}
int n;
point pts[MAXN];
int dot(vec &p1,vec &p2)
{int rt=0;for(int i=0;i<5 ;i++ ){rt+=p1.a[i]*p2.a[i];}return rt;
}
///根据鸽巢原理可以大幅度降低复杂度
///向量是有方向的
int main()
{
//    freopen("in.txt","r",stdin);cin>>n;for(int i=1;i<=n ;i++ ){cin>>pts[i];}vector<int>ans;if(n<3){for(int i=1;i<=n ;i++ ){ans.push_back(i);}}else if(n<=11)for(int i=1;i<=n ;i++ ){vector<vec>v;for(int j=1;j<=n ;j++ ){if(i!=j)v.push_back(mkvec(pts[i],pts[j]));}bool ok=true;for(int k=0;k<v.size() ;k++ ){for(int u=k+1;u<v.size() ;u++ ){if(dot(v[k],v[u])>0)ok=false;}}if(ok)ans.push_back(i);}cout<<ans.size()<<endl;for(int i=0;i<ans.size() ;i++ ){cout<<ans[i]<<endl;}
}

转载于:https://www.cnblogs.com/MalcolmMeng/p/10195067.html

codeforces 850 A相关推荐

  1. CodeForces 375D Tree and Queries

    传送门:https://codeforces.com/problemset/problem/375/D 题意: 给你一颗有根树,树上每个节点都有其对应的颜色,有m次询问,每次问你以点v为父节点的子树内 ...

  2. 「日常训练」Bad Luck Island(Codeforces Round 301 Div.2 D)

    题意与分析(CodeForces 540D) 是一道概率dp题. 不过我没把它当dp做... 我就是凭着概率的直觉写的,还好这题不算难. 这题的重点在于考虑概率:他们喜相逢的概率是多少?考虑超几何分布 ...

  3. 【codeforces 812C】Sagheer and Nubian Market

    [题目链接]:http://codeforces.com/contest/812/problem/C [题意] 给你n个物品; 你可以选购k个物品;则 每个物品有一个基础价值; 然后还有一个附加价值; ...

  4. CodeForces 获得数据

    针对程序的输出可以看见 CodeForces :当输入.输出超过一定字符,会隐藏内容 所以:分若干个程序进行输入数据的获取 1. 1 for (i=1;i<=q;i++) 2 { 3 scanf ...

  5. codeforces水题100道 第二十七题 Codeforces Round #172 (Div. 2) A. Word Capitalization (strings)...

    题目链接:http://www.codeforces.com/problemset/problem/281/A 题意:将一个英文字母的首字母变成大写,然后输出. C++代码: #include < ...

  6. CodeForces 595A

    题目链接: http://codeforces.com/problemset/problem/595/A 题意: 一栋楼,有n层,每层有m户,每户有2个窗户,问这栋楼还有多少户没有睡觉(只要一个窗户灯 ...

  7. codeforces A. Jeff and Digits 解题报告

    题目链接:http://codeforces.com/problemset/problem/352/A 题目意思:给定一个只有0或5组成的序列,你要重新编排这个序列(当然你可以不取尽这些数字),使得这 ...

  8. Codeforces Round #506 (Div. 3)

    Codeforces Round #506 (Div. 3) 实习期间事不多,对div3 面向题解和数据编程了一波 A. Many Equal Substrings 题目链接 A题就是找后缀和前缀重合 ...

  9. Codeforces Round #417:E. FountainsSagheer and Apple Tree(树上博弈)

    Codeforces Round #417:E. FountainsSagheer and Apple Tree(树上博弈) 标签: codeforces 2017-06-02 11:41 29人阅读 ...

最新文章

  1. 【数字孪生】工业互联网和数字孪生
  2. Android——使用Toolbar + DrawerLayout快速实现高大上菜单侧滑(转)
  3. python 周末大作业之2
  4. 数据中心智能电源分配器(PDU)的趋势与应用
  5. C/Cpp / 野指针和悬空指针
  6. 【EI/Scopus检索】第六届电子技术与信息科学国际学术会议诚邀您投稿参会!
  7. 说说C语言运算符的“优先级”与“结合性”
  8. 互联网晚报 | 2月18日 星期五 | 高途宣布停止高中学科辅导服务;小红书启动最严医美专项治理;FF 91量产版2月23日发布...
  9. APT的源列表--sources.list
  10. Laravel同时接收路由参数和查询字符串中的参数
  11. ubuntu16.0.4安装mysql5.7以及设置远程访问
  12. ztree 异步展开节点显示不出来_用户管理、角色管理、模块管理、zTree的使用
  13. 苹果分屏软件_Mac软件推荐
  14. 微信小程序—连接MQTT
  15. 在XP上将Office 2003升级到2010或并排运行
  16. Android当前任务管理器不显示应用进程
  17. FPGA Verilog语言常用语法
  18. 人,还是要去大城市!
  19. OCP 11G 051题库解析汇总链接
  20. 加那些YY主播的微信为何要花钱?

热门文章

  1. linux下find命令之-exec ll -sh {} \;
  2. [ warning] [vmusr:vmtoolsd] Failed registration of app type 2 (Signals)
  3. Know more about commit
  4. SSIS常用的包—大量插入任务(Bulk Insert task)
  5. 技术中国论坛版本升级了!
  6. 中医提到的气是否真实存在?
  7. Kafka->Flink->Hbase(纯DDL/DML形式)
  8. 菜鸟教程-HTML 教程学习笔记
  9. 7.4.8 数据压缩
  10. WIN10 软连接释放c盘空间