xjoi奋斗群群赛4

来源:互联网 发布:高级软件测试书 编辑:程序博客网 时间:2024/05/16 12:56

https://vjudge.net/contest/183699#problem

A - Arpa and a research in Mexican wave

题意

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(人数)=10,k(站起的最大人数)=5 的情况下,各个t的站起人数.
  • 给出n,k,t,求站起的人数.

题解

#include<cstdio>int main(){    long long n,k,t;    scanf("%lld%lld%lld",&n,&k,&t);    if(t<=k)    {        printf("%lld",t);        return  0;    }    if(t>=n)    {        printf("%lld",n+k-t);           return 0;    }    if(t<n&&t>k) printf("%lld",k);}

B - Arpa and an exam about geometry

题意

  • 一个平面上三个点a,b,c;问是否能找到一个点,使平面绕这个点旋转一定角度而使a移动到b,b移动到c.

思路

  • 若使AB=BC且a,b,c不在一条直线上,即可

题解

#include<cstdio>long long dis(long long x,long long y){    return (long long)x*x+(long long)y*y;}int main(){    long long ax,ay,bx,by,cx,cy;    scanf("%lld%lld%lld%lld%lld%lld",&ax,&ay,&bx,&by,&cx,&cy);    if(dis(ax-bx,ay-by)!=dis(bx-cx,by-cy)) printf("No");    else    {        if((ay-by)*(bx-cx)==(ax-bx)*(by-cy))            printf("No");        else printf("Yes");    }}

C - Five Dimensional Points

题意

  • 求一些五维点中的好点
  • 好点指任意由这个点与其他两个点组成的两个向量,向量的角度大于等于90°.

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.
Input
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.
Output
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.
Example
Input
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
Output
1
1
Input
3
0 0 1 2 0
0 0 9 2 0
0 0 5 9 0
Output
0
Note
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.

题解

#include<cstdio>#include<cmath>const int N=1010;int n,a[N][5],ans[N],an=0;int judge(int o,int p,int q){    int x[5],y[5];    for(int i=0;i<5;i++)    {        x[i]=a[o][i]-a[p][i];        y[i]=a[o][i]-a[q][i];    }    int tmp1=0;    for(int i=0;i<5;i++)    {        tmp1+=x[i]*y[i];    }    return tmp1;}void input(){    scanf("%d",&n);    for(int i=1;i<=n;i++)        for(int j=0;j<5;j++)            scanf("%d",&a[i][j]);}int main(){    input();    if(n>11)    {        printf("0");        return 0;    }    for(int i=1;i<=n;i++)    {        bool b=1;        for(int j=1;j<=n;j++)        {            if(j==i) continue;            for(int k=1;k<j;k++)            {                if(k==i) continue;                if(judge(i,j,k)>0)                {                    b=0; break;                }            }            if(b==0) break;        }        if(b) ans[++an]=i;    }    printf("%d\n",an);    for(int i=1;i<=an;i++) printf("%d ",ans[i]);}

D - Polycarpus’ Dice

题意

  • n个骰子,每个骰子的值可以是1~d[i],给出掷骰子的结果,求每个骰子不可能出现的值数.

题解

#include<cstdio>#include<algorithm>using namespace std;const int N=200010;long long n,s,b[N],sum=0;int main(){    scanf("%d%lld",&n,&s);    for(int i=1;i<=n;i++)    {        scanf("%d",b+i);        sum+=b[i];    }    for(int i=1;i<=n;i++)    {        int ans=0;        long long tmp1=s-(sum-b[i]);        if(tmp1>1) ans+=tmp1-1;        if(s<b[i]+n-1) ans+=b[i]+n-1-s;        if(ans>b[i]) ans=b[i];        printf("%d ",ans);    }}

E - Little Elephant and LCM

题意

-

思路

  • 枚举每个最小公倍数的可能,然后列出它的因数,对于每个a[i],其中可填的数的个数即小于等于它的因数个数。在保证最小公倍数被计入的情况下将每个a[i]的可能相乘。
  • 预处理每个数的因数。
原创粉丝点击