2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 A,D
A链接:https://www.nowcoder.com/acm/contest/163/A
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
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.
................
............................................................复制的有毒
输出描述:
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 题意:求一条直线,至少经过 N 个点中的 N * k 个点 解析 我感觉是随机写,题解也是, 那就随机吧。。。。 https://acm.ecnu.edu.cn/wiki/index.php?title=2018_ACM-ICPC_China_Shanghai_Metropolitan_Invitational_Contest
AC代码
#include <bits/stdc++.h>
#define LL long long
#define PI 3.1415926535897932384626
#define maxn 10050
#define EXIT exit(0);
#define DEBUG puts("Here is a BUG");
#define CLEAR(name, init) memset(name, init, sizeof(name))
const double eps = 1e-;
const int MAXN = 1e9 + ;
using namespace std;
#define Vector Point
int dcmp(double x)
{
return fabs(x) < eps ? : (x < ? - : );
}
struct Point
{
double x, y; Point(const Point& rhs): x(rhs.x), y(rhs.y) { } //拷贝构造函数
Point(double x = 0.0, double y = 0.0): x(x), y(y) { } //构造函数 friend istream& operator >> (istream& in, Point& P)
{
return in >> P.x >> P.y;
}
friend ostream& operator << (ostream& out, const Point& P)
{
return out << P.x << ' ' << P.y;
}
friend Vector operator + (const Vector& A, const Vector& B)
{
return Vector(A.x+B.x, A.y+B.y);
}
friend Vector operator - (const Point& A, const Point& B)
{
return Vector(A.x-B.x, A.y-B.y);
}
friend Vector operator * (const Vector& A, const double& p)
{
return Vector(A.x*p, A.y*p);
}
friend Vector operator / (const Vector& A, const double& p)
{
return Vector(A.x/p, A.y/p);
}
friend bool operator == (const Point& A, const Point& B)
{
return dcmp(A.x-B.x) == && dcmp(A.y-B.y) == ;
}
friend bool operator < (const Point& A, const Point& B)
{
return A.x < B.x || (A.x == B.x && A.y < B.y);
}
void in(void)
{
scanf("%lf%lf", &x, &y);
}
void out(void)
{
printf("%lf %lf", x, y);
}
};
template <class T> T sqr(T x)
{
return x * x;
}
double Dot(const Vector& A, const Vector& B)
{
return A.x*B.x + A.y*B.y; //点积
}
double Length(const Vector& A)
{
return sqrt(Dot(A, A));
}
double Angle(const Vector& A, const Vector& B)
{
return acos(Dot(A, B)/Length(A)/Length(B)); //向量夹角
}
double Cross(const Vector& A, const Vector& B)
{
return A.x*B.y - A.y*B.x; //叉积
}
double Area(const Point& A, const Point& B, const Point& C)
{
return fabs(Cross(B-A, C-A));
}
Vector normal(Vector x)
{
return Point(-x.y, x.x) / Length(x);
}
double angle(Vector x)
{
return atan2(x.y, x.x);
}
Point p[maxn];
int main()
{
int t,n;
double m; cin>>t;
while(t--)
{
cin>>n>>m;
for(int i=;i<=n;i++)
p[i].in();
int cnt=,ans,flag=;
while(cnt--)
{
int a=rand()%n+,b=rand()%n+;
if(a==b)continue;
ans=;
for(int i=;i<=n;i++)
{
if(fabs(Cross(p[i]-p[a],p[b]-p[a])-)<eps)
ans++;
}
if(ans*>=n*m*)
{
flag=;break;
}
}
if(flag==)
printf("No\n");
else
printf("Yes\n");
}
}
D链接:https://www.nowcoder.com/acm/contest/163/D
He first drew a regular polygon of N sides, and the length of each side is a.
He want to get a regular polygon of N sides, and the polygon area is no more than L.
He doesn't want to draw a new regular polygon as it takes too much effort.
So he think a good idea, connect the midpoint of each edge and get a new regular polygon of N sides.
How many operations does it need to get the polygon he want?
输入描述:
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 three space-separated integers N, a and L (3 ≤ N ≤ 10, 1 ≤ a ≤ 100, 1 ≤ L ≤ 1000).
输出描述:
For each test case, output a single integer.
输入例子:
1
4 2 3
输出例子:
1
-->
输入
1
4 2 3
输出
1 题意 正n多边形,边长为a,每次都取边的中点为新的顶点,连成多边形,直到多边形面积不大于L 解析 正n多边形的面积 很容易求得, 新的多边形还是正n多边形,只不过边长变为了 a*sqrt(1-cos(内角)/2)<余弦定理得> AC代码
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(), (a).end()
#define fillchar(a, x) memset(a, x, sizeof(a))
#define huan printf("\n");
#define debug(a,b) cout<<a<<" "<<b<<" "<<endl;
#define PI 3.1415926535897932384626
using namespace std;
typedef long long ll;
const int maxn=1e7+,inf=1e18;
const ll mod=1e9+;
const double eps = 1e-;
double normalpolygonarea(int n,double a)
{
double h=(a/)/tan(PI/n);
double triangle=a*h/;
return triangle*n;
}
int main()
{
int n,m,t;
double a;
cin>>t;
while(t--)
{
cin>>n>>a>>m;
int ans=;
double angle=(n-)*PI/n;
while((normalpolygonarea(n,a)-m)>eps)
{
a=sqrt((-cos(angle))/)*a;
ans++;
}
cout<<ans<<endl;
}
}
2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 A,D的更多相关文章
- 2018 ACM 国际大学生程序设计竞赛上海大都会部分题解
题目链接 2018 ACM 国际大学生程序设计竞赛上海大都会 下午午休起床被同学叫去打比赛233 然后已经过了2.5h了 先挑过得多的做了 .... A题 rand x*n 次点,每次judge一个点 ...
- 2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 F Color it
链接:https://www.nowcoder.com/acm/contest/163/F 来源:牛客网 2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 F Color it 时间限制:C ...
- 2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 F Color it (扫描线)
2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 F Color it (扫描线) 链接:https://ac.nowcoder.com/acm/contest/163/F来源:牛客网 时间 ...
- 2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 J Beautiful Numbers (数位DP)
2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 J Beautiful Numbers (数位DP) 链接:https://ac.nowcoder.com/acm/contest/163/ ...
- 2018 ACM 国际大学生程序设计竞赛上海大都会赛
传送门:2018 ACM 国际大学生程序设计竞赛上海大都会赛 2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛2018-08-05 12:00:00 至 2018-08-05 17:00:0 ...
- 2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 J Beautiful Numbers (数位dp)
题目链接:https://ac.nowcoder.com/acm/contest/163/J 题目大意:给定一个数N,求区间[1,N]中满足可以整除它各个数位之和的数的个数.(1 ≤ N ≤ 1012 ...
- 2018 ACM 国际大学生程序设计竞赛上海大都会 F - Color it (扫描线)
题意:一个N*M的矩形,每个点初始都是白色的,有Q次操作,每次操作将以(x,y)为圆心,r为半径的区域涂成黑点.求最后剩余白色点数. 分析:对每行,将Q次操作在该行的涂色视作一段区间,那么该行最后的白 ...
- 2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛-B-Perfect Numbers(完数)
题目描述 We consider a positive integer perfect, if and only if it is equal to the sum of its positive d ...
- 2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛-K-Matrix Multiplication(矩阵乘法)
题目描述 In mathematics, matrix multiplication or matrix product is a binary operation that produces a m ...
随机推荐
- redis集群架构(含面试题解析)
老规矩,我还是以循序渐进的方式来讲,我一共经历过三套集群架构的演进! Replication+Sentinel 这套架构使用的是社区版本推出的原生高可用解决方案,其架构图如下! 这里Sentinel的 ...
- 消息中间件与RPC的区别
消息中间件和消息通信与RPC各自具有怎样的优势,如何互补消息中间件主要实现的是异步.弹性消息以及队列,弹性消息有时可以借助于外存从而一定程度上可以实现峰值缓存,有效均衡服务器端压力,同时消息可以进行一 ...
- centos 更换yum源 (解决下载慢的问题)
先看有没有安装wget wget -V 如果没有执行 yum -y install wget 进行安装 然后进行配置的备份 mv /etc/yum.repos.d/CentO ...
- 初识WEBGL
WEBGL (全写Web Graphics Library)是一种3D绘图协议,这种绘图技术标准允许把JavaScript和OpenGL ES 2.0结合在一起,通过增加OpenGL ES 2.0的一 ...
- arx 地址
2014(32位和64位版本) ObjectARX 2014 SDKObjectARX 2014 帮助文档2013(32位和64位版本) ObjectARX 2013 SDKObjectARX 201 ...
- ES6(vue)对象词法扩展
ES6 允许声明在对象字面量时使用简写语法,来初始化属性变量和函数的定义方法,并且允许在对象属性中进行计算操作: function getCar(make, model, value) { retur ...
- GetForgroundWindow函数的不确定性——BUG笔记
HWND GetForgoundWindows() 获取当前前置窗口在windows 7和windows 10下虚拟桌面切换后表现不同. 所以强烈不建议使用此函数!
- Linux-04 Linux中Tomcat和MySQL的安装
1.下载apache-tomcat-7.0.79-tar.tar2.解压到当前用户目录,改名为tomcat [hduser@node1 ~]$ tar -zxvf apache-tomcat-7.0. ...
- WebGL 绘制Line的bug(二)
上一篇文章简单介绍了WebGL绘制Line的bug,不少朋友给我发了私信,看来这个问题大家都遇上过哈.今天这篇文章会讲述解决这个问题的work around. 基本思路 上一篇文章结尾简单提了下解决的 ...
- tab bar controller
下面记一下怎样通过代码的方式为选项卡添加视图. 1.创建一个基于Empty Application的项目 2.创建两个新类,基类选择UIViewController,勾选With XIB for us ...