河南省第六届ACM程序设计大赛(共7道,目前只做了三道。待续)

来源:互联网 发布:mac flash player 编辑:程序博客网 时间:2024/03/29 05:33
  • 题目709
  • 题目信息
  • 运行结果
  • 本题排行
  • 讨论区

异 形 卵

时间限制:1000 ms  |  内存限制:65535 KB
难度:2
描述

我们探索宇宙,是想了解浩瀚星空的奥妙,但我们却很少意识到宇宙深处藏匿的危险,它们无时无刻不紧盯着我们的地球。如果外星人拜访我们,结果可能与哥伦布当年踏足美洲大陆不会有什么两样,这是历史,也是现实。

在ZDM-777星球上发现的休眠异形卵,其外表与常见的卵不同,表面被一层石墨覆盖。当人走近时,那层石墨开始消融,能看到里面的异形卵正在活动,异形卵是活物,具备一些热量或压力传感器这些基本的中枢神经系统,通过感知周围的热量,选择热量最大处寄生。不过,假如周围有不适合被寄生处,异形卵就选择休眠。

周围的热量可以用一串整数a1,a2,……,an来表示,异形卵具有一定的长度L,异形卵总是选择ai+ai+1+…+ai+L-1达到最大值处寄生。若周围的热量低于0,异形卵则选择休眠。

异形卵是如何感知它的寄生处呢?我们探索宇宙,是想了解浩瀚星空的奥妙,但我们却很少意识到宇宙深处藏匿的危险,它们无时无刻不紧盯着我们的地球。如果外星人拜访我们,结果可能与哥伦布当年踏足美洲大陆不会有什么两样,这是历史,也是现实。

在ZDM-777星球上发现的休眠异形卵,其外表与常见的卵不同,表面被一层石墨覆盖。当人走近时,那层石墨开始消融,能看到里面的异形卵正在活动,异形卵是活物,具备一些热量或压力传感器这些基本的中枢神经系统,通过感知周围的热量,选择热量最大处寄生。不过,假如周围有不适合被寄生处,异形卵就选择休眠。

周围的热量可以用一串整数a1,a2,……,an来表示,异形卵具有一定的长度L,异形卵总是选择ai+ai+1+…+ai+L-1达到最大值处寄生。若周围的热量低于0,异形卵则选择休眠。

异形卵是如何感知它的寄生处呢?

输入
第一行: K 表示有多少组测试数据。 
接下来对每组测试数据有2行,第1行: L N 
第2行:a1 a2 …… aN

【约束条件】
2≤K≤5 L≤N, 1≤L≤10 1≤N≤1000 -100≤ ai≤100 
数据之间有一个空格。

输出
对于每组测试数据,输出一行:异形卵能寄生的起始位置。若有多处可以寄生,则选择小的起始位置。若无处可以寄生,则输出0。
样例输入
23 530  0 100 -30 1003 5-100 80 -80 -100  80
样例输出
30
来源
第六届河南省程序设计大赛
上传者

ACM_赵铭浩


#include <stdio.h>int main(){    int n,l,i,j,k,a[1010],sum[1010];    scanf("%d",&k);    while(k--)    {        scanf("%d%d",&l,&n);        for(i=0;i<n;i++)            scanf("%d",&a[i]);        int max=0,temp=0;        for(j=0;j<=n-l;j++)        {            //printf("%d\n",max);            sum[j]=0;            for(i=j;i<j+l;i++)            {                sum[j]+=a[i];            }            //printf("%d\n",sum);            if(sum[j]>max)            {                max=sum[j];                temp=j+1;            }        }        printf("%d\n",temp);    }    return 0;}


外星人的供给站

时间限制:1000 ms  |  内存限制:65535 KB
难度:3
描述

外星人指的是地球以外的智慧生命。外星人长的是不是与地球上的人一样并不重要,但起码应该符合我们目前对生命基本形式的认识。比如,我们所知的任何生命都离不开液态水,并且都是基于化学元素碳(C)的有机分子组合成的复杂有机体。

42岁的天文学家Dr. Kong已经执著地观测ZDM-777星球十多年了,这个被称为“战神”的红色星球让他如此着迷。在过去的十多年中,他经常有一些令人激动的发现。ZDM-777星球表面有着明显的明暗变化,对这些明暗区域,Dr. Kong已经细致地研究了很多年,并且绘制出了较为详尽的地图。他坚信那些暗区是陆地,而亮区则是湖泊和海洋。他一直坚信有水的地方,一定有生命的痕迹。Dr. Kong有一种强烈的预感,觉得今天将会成为他一生中最值得纪念的日子。
    这天晚上的观测条件实在是空前的好,ZDM-777星球也十分明亮,在射电望远镜中呈现出一个清晰的暗红色圆斑。还是那些熟悉的明暗区域和极冠,不过,等等,Dr. Kong似乎又扑捉到曾看到过的东西,那是什么,若隐若现的。他尽可能地睁大了眼睛,仔细地辨认。哦,没错,在一条直线上,又出现了若干个极光点连接着星球亮区,几分钟后,极光点消失。

Dr. Kong大胆猜想,ZDM-777星球上的湖泊和海洋里一定有生物。那些极光点就是ZDM-777星球上的供给站,定期给这些生物提出维持生命的供给。

不妨设,那条直线为X轴,极光点就处在X轴上,N个亮区P1,P2,…Pn就分布在若干个极光点周围。



接着,Dr. Kong 又有惊人的发现,所有的亮区Pi都处在某个半径为R的极光点圆内。去掉一个极光点就会有某些亮区Pj不处在覆盖区域内。

Dr. Kong想知道,至少需要多少个极光点才能覆盖所有的湖泊和海洋。
输入
第一行: K 表示有多少组测试数据。 
接下来对每组测试数据:
第1行: N R
第2~N+1行: PXi PYi (i=1,…..,N)

【约束条件】
2≤K≤5 1≤R≤50 1≤N≤100 -100≤PXi PYi≤100 | PYi | ≤ R 
R, PXi PYi都是整数。数据之间有一个空格。
输出
对于每组测试数据,输出一行: 最少需要的极光点数。
样例输入
23 21 2-3 12 11 55 5
样例输出
21
来源
第六届河南省程序设计大赛
上传者
ACM_赵铭浩

#include<cstdio>  #include<cmath>  #include<algorithm>  using namespace std;  struct radar  {         double left,right;  }a[1005];  bool comp(radar a1,radar a2)  {       return a1.left<a2.left;  }  int main()  {      int n,r,x,y,count,t,i;      double p,len;      scanf("%d",&t);      while(t--)      {          scanf("%d%d",&n,&r);          for(i=0;i<n;i++)          {              scanf("%d%d",&x,&y);              len=sqrt((double)r*r-(double)y*y);              a[i].left=x-len;              a[i].right=x+len;          }          sort(a,a+n,comp);          p=a[0].right;          count=1;          for(i=1;i<n;i++)          {              if(a[i].left>p)              {                  count++;                  p=a[i].right;              }              else               {                  if(a[i].right<p)                  p=a[i].right;              }          }          printf("%d\n",count);      }      return 0;  }


最舒适的路线

时间限制:5000 ms  |  内存限制:65535 KB
难度:5
描述

异形卵潜伏在某区域的一个神经网络中。其网络共有N个神经元(编号为1,2,3,…,N),这些神经元由M条通道连接着。两个神经元之间可能有多条通道。异形卵可以在这些通道上来回游动,但在神经网络中任一条通道的游动速度必须是一定的。当然异形卵不希望从一条通道游动到另一条通道速度变化太大,否则它会很不舒服。

现在异形卵聚居在神经元S点,想游动到神经元T点。它希望选择一条游动过程中通道最大速度与最小速度比尽可能小的路线,也就是所谓最舒适的路线。

输入
第一行: K 表示有多少组测试数据。 
接下来对每组测试数据:
第1行: N M
第2~M+1行: Xi Yi Vi (i=1,…..,M)
表示神经元Xi 到神经元Yi之间通道的速度必须是Vi
最后一行: S T ( S  T )

【约束条件】
2≤K≤5 1<N≤500 0<M≤5000 1≤ Xi, Yi , S , T ≤N 0< Vi <30000,
Vi是整数。数据之间有一个空格。
输出
对于每组测试数据,输出一行:如果神经元S到神经元T没有路线,输出“IMPOSSIBLE”。否则输出一个数,表示最小的速度比。如果需要,输出一个既约分数。
样例输入
23 21 2 22 3 41 33 31 2 101 2 52 3 81 3
样例输出
25/4
来源
第六届河南省程序设计大赛
上传者
ACM_赵铭浩

探 寻 宝 藏

时间限制:1000 ms  |  内存限制:65535 KB
难度:5
描述

传说HMH大沙漠中有一个M*N迷宫,里面藏有许多宝物。某天,Dr.Kong找到了迷宫的地图,他发现迷宫内处处有宝物,最珍贵的宝物就藏在右下角,迷宫的进出口在左上角。当然,迷宫中的通路不是平坦的,到处都是陷阱。Dr.Kong决定让他的机器人卡多去探险。

但机器人卡多从左上角走到右下角时,只会向下走或者向右走。从右下角往回走到左上角时,只会向上走或者向左走,而且卡多不走回头路。(即:一个点最多经过一次)。当然卡多顺手也拿走沿路的每个宝物。

Dr.Kong希望他的机器人卡多尽量多地带出宝物。请你编写程序,帮助Dr.Kong计算一下,卡多最多能带出多少宝物。
输入
第一行: K 表示有多少组测试数据。 
接下来对每组测试数据:
第1行: M N
第2~M+1行: Ai1 Ai2 ……AiN (i=1,…..,m)


【约束条件】
2≤k≤5 1≤M, N≤50 0≤Aij≤100 (i=1,….,M; j=1,…,N)
所有数据都是整数。 数据之间有一个空格。
输出
对于每组测试数据,输出一行:机器人卡多携带出最多价值的宝物数
样例输入
22 30 10 1010 10 803 30 3 92 8 55 7 100
样例输出
120134
来源
第六届河南省程序设计大赛
上传者
ACM_赵铭浩


Card Trick

时间限制:1000 ms  |  内存限制:65535 KB
难度:3
描述

The magician shuffles a small pack of cards, holds it face down and performs the following procedure:

  1. The top card is moved to the bottom of the pack. The new top card is dealt face up onto the table. It is the Ace of Spades.
  2. Two cards are moved one at a time from the top to the bottom. The next card is dealt face up onto the table. It is the Two of Spades.
  3. Three cards are moved one at a time…
  4. This goes on until the nth and last card turns out to be the n of Spades.

This impressive trick works if the magician knows how to arrange the cards beforehand (and knows how to give a false shuffle). Your program has to determine the initial order of the cards for a given number of cards, 1 ≤ n ≤ 13.

输入
On the first line of the input is a single positive integer k, telling the number of test cases to follow. 1 ≤ k ≤ 10 Each case consists of one line containing the integer n. 1 ≤ n ≤ 13
输出
For each test case, output a line with the correct permutation of the values 1 to n, space separated. The first number showing the top card of the pack, etc…
样例输入
245
样例输出
2 1 4 33 1 4 5 2
来源
第六届河南省程序设计大赛
上传者
ACM_赵铭浩

#include<stdio.h>  #include<queue>  using namespace std;    int main()  {      queue<int> que;      int n;      int i,j,t,m,k;      int distion;      int c[14];      scanf("%d" ,&n);      while(n--)      {          scanf("%d",&m);          k = 1;          for(i= 1;i<=m;i++)          {              que.push(i);          }                    for(i = 1;i<=m;i++)          {                          for(j = 1;j<=i;j++)            {              t = que.front();              que.pop();              que.push(t);             }            distion = que.front();            c[distion] = k++;            que.pop();          }                    for(i = 1 ;i<= m ;i++)          if(i == 0)printf("%d",c[i]);          else printf(" %d",c[i]);          printf("\n");         }                    return 0;    }   


Adjacent Bit Counts

时间限制:1000 ms  |  内存限制:65535 KB
难度:4
描述

For a string of n bits x1, x2, x3, …, xn,  the adjacent bit count of the string  is given by     fun(x) = x1*x2 + x2*x3 + x3*x 4 + … + xn-1*x n
which counts the number of times a 1 bit is adjacent to another 1 bit. For example:  

     Fun(011101101) = 3

     Fun(111101101) = 4

     Fun (010101010) = 0

Write a program which takes as input integers n and p and returns the number of bit strings x of n bits (out of 2ⁿ) that satisfy  Fun(x) = p.

 

For example, for 5 bit strings, there are 6 ways of getting fun(x) = 2:

11100, 01110, 00111, 10111, 11101, 11011

输入
On the first line of the input is a single positive integer k, telling the number of test cases to follow. 1 ≤ k ≤ 10 Each case is a single line that contains a decimal integer giving the number (n) of bits in the bit strings, followed by a single space, followed by a decimal integer (p) giving the desired adjacent bit count. 1 ≤ n , p ≤ 100
输出
For each test case, output a line with the number of n-bit strings with adjacent bit count equal to p.
样例输入
25 220 8 
样例输出
663426
来源
第六届河南省程序设计大赛
上传者
ACM_赵铭浩


Adjacent Bit Counts

时间限制:1000 ms  |  内存限制:65535 KB
难度:4
描述

For a string of n bits x1, x2, x3, …, xn,  the adjacent bit count of the string  is given by     fun(x) = x1*x2 + x2*x3 + x3*x 4 + … + xn-1*x n
which counts the number of times a 1 bit is adjacent to another 1 bit. For example:  

     Fun(011101101) = 3

     Fun(111101101) = 4

     Fun (010101010) = 0

Write a program which takes as input integers n and p and returns the number of bit strings x of n bits (out of 2ⁿ) that satisfy  Fun(x) = p.

 

For example, for 5 bit strings, there are 6 ways of getting fun(x) = 2:

11100, 01110, 00111, 10111, 11101, 11011

输入
On the first line of the input is a single positive integer k, telling the number of test cases to follow. 1 ≤ k ≤ 10 Each case is a single line that contains a decimal integer giving the number (n) of bits in the bit strings, followed by a single space, followed by a decimal integer (p) giving the desired adjacent bit count. 1 ≤ n , p ≤ 100
输出
For each test case, output a line with the number of n-bit strings with adjacent bit count equal to p.
样例输入
25 220 8 
样例输出
663426
来源
第六届河南省程序设计大赛
上传者
ACM_赵铭浩



0 0