A链接: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.
................
............................................................复制的有毒

输出描述:

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

In order to become a magical girl, Thinking-Bear are learning magic circle.
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

输入

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;
}
}

最新文章

  1. CSS Hack
  2. Java—工厂模式
  3. c# base64 编码解码
  4. php curl 库使用
  5. 【BZOJ4260】 Codechef REBXOR 可持久化Trie
  6. 博客的开端,找对象不再new
  7. 关于 Visual Studio 调试 Global 的一点总结
  8. Linux - 文本格式转换
  9. ffmpeg之YUYV转RGB ARM使用流程分析
  10. Kubernetes运维生态-Heapster分析
  11. 大数据及hadoop相关知识介绍
  12. Python学习笔记007_图形用户界面[EasyGui][Tkinter]
  13. Pythonh中的zip()与*zip()函数详解
  14. Jerry的ABAP, Java和JavaScript乱炖
  15. 10_Android中通过HttpUrlConnection访问网络,Handler和多线程使用,读取网络html代码并显示在界面上,ScrollView组件的使用
  16. ssm项目跨域访问
  17. excel、xls文件读写操作
  18. Entity Framework 6.1.0 Tools for Visual Studio 2012 &amp; 2013
  19. STM32 外部中断
  20. 超简易复制Model对象(为后续备忘录设计模式博文做铺垫)

热门文章

  1. 50个Bootstrap扩展插件
  2. vSphere Client用户名密码保存记录
  3. Fire Air(华科校赛 网络赛)
  4. Lampiao(dirtycow)脏牛漏洞复现
  5. js将时间戳装换成日期格式
  6. eclipse修改SVN账号密码
  7. 牛客noip前集训营(第一场)提高T1
  8. LNOI2019划水记
  9. NFS和DHCP服务
  10. 企业级监控nagios实践