Arpa is researching the Mexican wave.
There are n spectators in the stadium, labeled from 1 to n. They start the Mexican wave at time 0.
- At time 1, the first spectator stands.
- At time 2, the second spectator stands.
- ...
- At time k, the k-th spectator stands.
- At time k + 1, the (k + 1)-th spectator stands and the first spectator sits.
- At time k + 2, the (k + 2)-th spectator stands and the second spectator sits.
- ...
- At time n, the n-th spectator stands and the (n - k)-th spectator sits.
- At time n + 1, the (n + 1 - k)-th spectator sits.
- ...
- At time n + k, the n-th spectator sits.
Arpa wants to know how many spectators are standing at time t.
The first line contains three integers n, k, t (1 ≤ n ≤ 109, 1 ≤ k ≤ n, 1 ≤ t < n + k).
Print single integer: how many spectators are standing at time t.
10 5 3
3
10 5 7
5
10 5 12
3
In the following a sitting spectator is represented as -, a standing spectator is represented as ^.
- At t = 0 ----------
number of standing spectators = 0.
- At t = 1 ^---------
number of standing spectators = 1.
- At t = 2 ^^--------
number of standing spectators = 2.
- At t = 3 ^^^-------
number of standing spectators = 3.
- At t = 4 ^^^^------
number of standing spectators = 4.
- At t = 5 ^^^^^-----
number of standing spectators = 5.
- At t = 6 -^^^^^----
number of standing spectators = 5.
- At t = 7 --^^^^^---
number of standing spectators = 5.
- At t = 8 ---^^^^^--
number of standing spectators = 5.
- At t = 9 ----^^^^^-
number of standing spectators = 5.
- At t = 10 -----^^^^^
number of standing spectators = 5.
- At t = 11 ------^^^^
number of standing spectators = 4.
- At t = 12 -------^^^
number of standing spectators = 3.
- At t = 13 --------^^
number of standing spectators = 2.
- At t = 14 ---------^
number of standing spectators = 1.
- At t = 15 ----------
number of standing spectators = 0.
就是分段讨论即可。n+k为一个周期。
#include<bits/stdc++.h>
using namespace std;
int main(){
long long n , k ,t;
while(cin>>n>>k>>t){
if(t>=n+k)t=t-(n+k)*(t/(n+k));
if(t<=k)
cout<<t<<endl;
else if (t>=n)cout<<k-t+n<<endl;
else
cout<<k<<endl;
}
return 0;
}
所以肯定只有当abc是圆弧的一段,并且b是弧abc的中点时候才可以。
所以只需要判断ab=bc,并且abc不共线即可。(不共线可用海伦公式求)
//不知道为啥 我讨论斜率不存在反而多余了- - 不考虑反而过了
#include<bits/stdc++.h>
using namespace std;
#define INF 100861111
#define ll long long
#define eps 1e-5
#define maxn 20
int main()
{
double x1,y1,x2,y2,x3,y3,k1,k2,d1,d2;
scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3);
d1=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
d2=(x2-x3)*(x2-x3)+(y2-y3)*(y2-y3);
if(d1!=d2)
{
printf("No\n");
return 0;
}
k1=(y1-y2)/(x1-x2);
k2=(y2-y3)/(x2-x3);
if(k1==k2)
{
printf("No\n");
}
else
printf("Yes\n");
return 0;
}
You are given set of n points in 5-dimensional space. The points are labeled from 1 to n. No two points coincide.
We will call point a bad if there are different points b and c, not equal to a, from the given set such that angle between vectors and
is acute (i.e. strictly less than
). Otherwise, the point is called good.
The angle between vectors and
in 5-dimensional space is defined as
, where
is the scalar product and
is length of
.
Given the list of points, print the indices of the good points in ascending order.
The first line of input contains a single integer n (1 ≤ n ≤ 103) — the number of points.
The next n lines of input contain five integers ai, bi, ci, di, ei (|ai|, |bi|, |ci|, |di|, |ei| ≤ 103) — the coordinates of the i-th point. All points are distinct.
First, print a single integer k — the number of good points.
Then, print k integers, each on their own line — the indices of the good points in ascending order.
6 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1
1 1
3 0 0 1 2 0 0 0 9 2 0 0 0 5 9 0
0
In the first sample, the first point forms exactly a angle with all other pairs of points, so it is good.
In the second sample, along the cd plane, we can see the points look as follows:
We can see that all angles here are acute, so no points are good.
题意:
有n个五维的点,求有多少个“好“点,对于“好”点、“坏”点的定义如下:
“好”点:设该点为a,在所给点中任意两个不相等且不为a的点b,c,向量ab与向量bc的夹角均不为锐角。
“坏”点:不是“好”点的点都是“坏”点
可以从二维三维的方向来考虑,在二维中,一个“好”点的周围最多有4个点(x正负方向两个,y正负方向两个),三维则有6个(加上z方向上两个),可以知道,五维的情况下,一个“好”点周围最多有10个点,加上自身,即图中有“好”点的情况下,最多有11个点,即n>11时不可能存在“好”点,然后n<=11的情况就枚举一下就行了。
#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
int arr[1001][5];
int ans[1001];
int main()
{
int n;
cin>>n;
if(n<3)
{
for(int i = 0;i<n;i++)
{
int a;
scanf("%d%d%d%d%d%d",&a,&a,&a,&a,&a,&a);
}
printf("%d\n",n);
for(int i = 0;i<n;i++)
printf("%d\n",i+1);
}
else
{
for(int i = 0;i<n;i++)
{
for(int j = 0;j<5;j++)
{
scanf("%d",&arr[i][j]);
}
}
int len = 0;
for(int i = 0;i<n;i++)
{
int flag = 0;
for(int j = 0;j<n&&flag==0;j++)
{
if(i==j)
continue;
for(int k = 0;k<n&&flag==0;k++)
{
if(k==i||k==j)
continue;
double xy = 0,xx = 0,yy = 0;
for(int z = 0;z<5;z++)
{
xx += (arr[j][z]-arr[i][z])*(arr[j][z]-arr[i][z]);
yy += (arr[k][z]-arr[i][z])*(arr[k][z]-arr[i][z]);
xy+=(arr[j][z]-arr[i][z])*(arr[k][z]-arr[i][z]);
}
double s=sqrt(xx)*sqrt(yy);
if(acos(xy/s)>=0&&acos(xy/s)<pi/2)
{
flag = 1;
}
}
}
if(!flag)
{
ans[len++] = i+1;
}
}
printf("%d\n",len);
for(int i = 0;i<len;i++)
printf("%d\n",ans[i]);
}
return 0;
}