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.
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-9; const int MAXN = 1e9 + 5; using namespace std; #define Vector Point int dcmp(double x) { return fabs(x) < eps ? 0 : (x < 0 ? -1 : 1); } 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) == 0 && dcmp(A.y-B.y) == 0; } 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=1;i<=n;i++) p[i].in(); int cnt=1000,ans,flag=0; while(cnt--) { int a=rand()%n+1,b=rand()%n+1; if(a==b)continue; ans=0; for(int i=1;i<=n;i++) { if(fabs(Cross(p[i]-p[a],p[b]-p[a])-0)<eps) ans++; } if(ans*10>=n*m*10) { flag=1;break; } } if(flag==0) 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?
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
输入
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+50,inf=1e18; const ll mod=1e9+7; const double eps = 1e-9; double normalpolygonarea(int n,double a) { double h=(a/2)/tan(PI/n); double triangle=a*h/2; return triangle*n; } int main() { int n,m,t; double a; cin>>t; while(t--) { cin>>n>>a>>m; int ans=0; double angle=(n-2)*PI/n; while((normalpolygonarea(n,a)-m)>eps) { a=sqrt((1-cos(angle))/2)*a; ans++; } cout<<ans<<endl; } }