2019ICPC南京站题解

A题大水题。

 1 #include <bits/stdc++.h>
 2 #define ll long long
 3 #define f(i,a,b) for(int i=a;i<=b;i++)
 4 #define scan(i) scanf("%d",&i)
 5 #define pf printf
 6 using namespace std;
 7
 8 int main()
 9 {
10     int n;
11     scan(n);
12     f(i,1,n){
13         int t;
14         scan(t);
15         if(t%2){
16             pf("%d\n",t/2+2);
17         }
18         else pf("%d\n",t/2+1);
19     }
20     return 0;
21 }

H题小水题,有两个wa点,第一是只有诚实的人且人数大于1人时直接输出1,第二是只有一个人且是诚实的时输出0。

 1 #include <bits/stdc++.h>
 2 #define ll long long
 3 #define f(i,a,b) for(int i=a;i<=b;i++)
 4 #define scan(i) scanf("%d",&i)
 5 #define pf printf
 6 using namespace std;
 7
 8 int main()
 9 {
10     int a,b,c;
11     scanf("%d%d%d",&a,&b,&c);
12     if(b==0&&c==0){
13         if(a==1){
14             pf("YES\n0");
15         }
16         else pf("YES\n1");
17     }
18     else if(a>b+c){
19         pf("YES\n%d",2*b+2*c+1);
20     }
21     else pf("NO");
22     return 0;
23 }

K题计算几何。使用了一个假板子,发现了问题所在,已更新板子。

 1 #include <bits/stdc++.h>
 2 #define ll long long
 3 #define f(i,a,b) for(int i=a;i<=b;i++)
 4 #define scan(i) scanf("%d",&i)
 5 #define pf printf
 6 using namespace std;
 7 const  double eps=1e-10;
 8 const double PI=acos(-1.0);
 9 using namespace std;
10 struct Point{
11     double x;
12     double y;
13     Point(double x=0,double y=0):x(x),y(y){}
14     void operator<<(Point &A) {cout<<A.x<<‘ ‘<<A.y<<endl;}
15     bool operator!=(Point &A) {if(fabs(A.x-x)>eps||fabs(A.y-y)>eps) return true;return false;}
16 };
17
18 int dcmp(double x)  {return (x>eps)-(x<-eps); }
19 int sgn(double x)  {return (x>eps)-(x<-eps); }
20 typedef  Point  Vector;
21
22 Vector  operator +(Vector A,Vector B) { return Vector(A.x+B.x,A.y+B.y);}
23 Vector  operator -(Vector A,Vector B) { return Vector(A.x-B.x,A.y-B.y); }
24 Vector  operator *(Vector A,double p) { return Vector(A.x*p,A.y*p);  }
25 Vector  operator /(Vector A,double p) {return Vector(A.x/p,A.y/p);}
26 ostream &operator<<(ostream & out,Point & P) { out<<P.x<<‘ ‘<<P.y<<endl; return out;}
27 bool  operator< (const Point &A,const Point &B) { return dcmp(A.x-B.x)<0||(dcmp(A.x-B.x)==0&&dcmp(A.y-B.y)<0); }
28 bool  operator== ( const Point &A,const Point &B) { return dcmp(A.x-B.x)==0&&dcmp(A.y-B.y)==0;}
29
30 double  Dot(Vector A,Vector B) {return A.x*B.x+A.y*B.y;}
31 double  Cross(Vector A,Vector B)  {return A.x*B.y-B.x*A.y; }
32 double  Length(Vector A)  { return sqrt(Dot(A, A));}
33 double  Angle(Vector A,Vector B) {return acos(Dot(A,B)/Length(A)/Length(B));}
34 double  Area2(Point A,Point B,Point C ) {return fabs(Cross(B-A, C-A));}
35
36 Vector Rotate(Vector A,double rad) { return Vector(A.x*cos(rad)-A.y*sin(rad),A.x*sin(rad)+A.y*cos(rad));}
37 Vector Normal(Vector A) {double L=Length(A);return Vector(-A.y/L,A.x/L);}
38
39 Point GetLineIntersection(Point P,Vector v,Point Q,Vector w){
40     if(v.x*w.y==v.y*w.x) return Point(5201314,5201314);
41     Vector u=P-Q;
42     double t=Cross(w, u)/Cross(v,w);
43     return P+v*t;
44 }//输入两个点斜式方程输出交点
45
46 bool  OnSegment(Point P,Point A,Point B){
47     return dcmp(Cross(P-A, P-B))==0&&dcmp(Dot(P-A,P-B))<=0;
48 }//输入三个点,判断P是否在线段AB上
49
50 double x1,x2,x3,x4,y11,y2,y3,y4;
51 int main()
52 {
53     int T;
54     scan(T);
55     f(kk,1,T){
56         scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x1,&y11,&x2,&y2,&x3,&y3,&x4,&y4);
57         Point a(x1,y11),b(x2,y2),c(x3,y3),p(x4,y4);
58         int x=0;
59         if(OnSegment(p,a,b)) x=1;
60         else if(OnSegment(p,a,c)) x=2;
61         else if(OnSegment(p,b,c)) x=3;
62         if(x==0) pf("-1\n");
63         else{
64             double area=Area2(a,b,c)/2;
65             if(x==2) swap(b,c);
66             else if(x==3) swap(a,c);
67             if(Length(p-a)>Length(p-b)){
68                 double angle=Angle(a-b,a-c);
69                 //area*0.5=0.5*a*b*sinx;
70                 double k=area/sin(angle)/Length(p-a)/Length(c-a);
71                 //cout<<k<<endl;
72                 Point ans=(c-a)*k+a;
73                 pf("%.10lf %.10lf\n",ans.x,ans.y);
74             }
75             else{
76                 double angle=Angle(b-a,b-c);
77                 //area*0.5=0.5*a*b*sinx;
78                 double k=area/sin(angle)/Length(p-b)/Length(c-b);
79                 //cout<<k<<endl;
80                 Point ans=(c-b)*k+b;
81                 pf("%.10lf %.10lf\n",ans.x,ans.y);
82             }
83         }
84     }
85 }

原文地址:https://www.cnblogs.com/St-Lovaer/p/11992417.html

时间: 2024-08-30 18:36:09

2019ICPC南京站题解的相关文章

2019ICPC徐州站题解

C题大水题,欧拉筛筛下素数,然后在线处理一下普通素数. 1 #include <bits/stdc++.h> 2 #define ll long long 3 #define scan(i) scanf("%d",&i) 4 #define scanl(i) scanf("%lld",&i) 5 #define scand(i) scanf("%lf",&i) 6 #define pf printf 7 #de

精彩回顾 | HDG南京站圆满落幕,交流、分享,接地气!

文/华为eSDK 5月28日,在南京黑马路演中心举办的HDG华为开发者汇于16:30圆满结束了.听着各路技术大咖分享经验,品着香醇的咖啡,吃着美味的披萨,这小日子,也是美美哒.你说错过了?没关系,小e这就带你感受一下精彩纷呈的现场~ 分 享 Share ▼ 作为一场专业的沙龙, 最重要的自然是干货分享! 随着主持人林旅强风趣幽默的暖场, 现场气氛立马活跃起来. 我们不仅邀请了华为内部的4位专家为大家讲解关于CaaS开放平台.CCE容器云.公有云及开源等领域的专业知识,还邀请到苏宁和途牛的一线互联

2020第十三届春季国际物联网展览会-南京站3月邀约各位大咖

邀 请 函 时间:2020年03月26-28日 地点:中国?南京国际会展中心4组织单位 特邀单位:××× ×××商务部主办单位:北京铭世博国际展览有限公司 支持单位:××× ×××中国智能家居产业联盟 中华物联网联盟国家信息化专家咨询委员会 中国物联网产业协会 承办单位:北京铭世博国际展览有限公司物联世界 智慧全球前言南京六朝古都是中国东部地区重要的中心城市.全国重要的科研基地和综合交通枢纽,是长江三角洲唯一的特大城市和长三角辐射带动中西部地区发展重要门户城市.首批国家历史文化名城和全国重点风景

2019ICPC南京网络赛A题 The beautiful values of the palace(三维偏序)

2019ICPC南京网络赛A题 The beautiful values of the palace https://nanti.jisuanke.com/t/41298 Here is a square matrix of n * nn?n, each lattice has its value (nn must be odd), and the center value is n * nn?n. Its spiral decline along the center of the squar

2019ICPC网赛南京站B题 super_log(欧拉降幂

https://nanti.jisuanke.com/t/41299 题意:让算a^(a^(a^(...))),一共b个a, (mod p)的结果. 思路:这是个幂塔函数,用欧拉降幂公式递归求解. #include<bits/stdc++.h> #define ll long long using namespace std; map<int,int> euler; ll a,b,mod; int phi(int n) { int now=n; int ret=n; if(eule

2013 ACM-ICPC亚洲区域赛南京站C题 题解 轮廓线DP

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4804 题目大意 给你一个 \(n \times m\) 的矩形区域.你需要用 \(1 \times 1\) 和 \(1 \times 2\) 的砖块铺满这个区域,且满足如下要求: 所有的砖块可以竖着放或横着放: 砖角要放在格点上: \(1 \times 1\) 的砖不能少于 \(C\) 块也不能多于 \(D\) 块, \(1 \times 2\) 的砖没有数量限制. 有些方格在一开始就已经被填充了,

&quot;尖叫之夜&quot;南京站激情开唱 冯建宇成颜值担当有惊喜

6月30日即将开唱的爱奇艺尖叫之夜南京演唱会已经放出嘉宾海报,除了罗志祥.迪玛希两位男神之外,"不一样的美男子"冯建宇也成阵容中的颜值担当.这位小哥也是不简单哦,凭借一部网剧一夜走红,演戏.唱歌做公益,粉丝爱他爱得要命,到底他是如何吸粉让粉丝对他无法自拔的? 自成名起,冯建宇就在演艺之路上走得风风火火,不仅出单曲开个唱,还在2016年首次担任酷音乐亚洲盛典红毯主持人,之后又涉足电影界,主演公路电影<一路向南>,并演唱该片主题曲. 不仅颜值高,冯建宇情商也很高,尤其对粉丝十分

架构师实践日 11.9 南京站报名 | 技术大牛带你剖析大数据平台内部演进中的挑战与实践

从互联网时代到物联网时代,数据成为了企业的核心资产,挖掘数据价值成为了企业数据探索.技术应用的重中之重,甚至将影响到企业未来的发展和商业模式.但大数据体量大.多样性.价值密度低.速度快等特征,也给大数据的应用研发工作带来了不少挑战. ? ? ? ? 如何应对大数据不断生长的有机特征,处理超大规模的数据挖掘?? ? 如何改进现有的数据存储与管理技术,以满足大数据应用中的大体量数据和高速数据流实时处理需求?? ? 如何解决大数据技术中的核心问题?? ? 为助力企业大数据技术应用,切实分析企业面临的数

2020第十一届国际智能家居展览会---南京站盛大召开

2020第十一届(南京)国际智能家居展览会 The 11th (nanjing) international smart home exhibition 2020同期举办:2020智能锁展览会At the same time: 2020 smart lock exhibition体验智能科技 畅享智能生活 时间:2020年03月26-28日 地点:南京国际展览中心 邀 请 函 批准单位: 北京市商务委员会主办单位: 北京铭世博国际展览有限公司 支持单位: 中国智能硬件行业协会 ×××中国智能家居