zoukankan      html  css  js  c++  java
  • ACM-东北大学程序设计竞赛-网络赛(2016.04.16)

    Problem: A

    Time limit: 1s    Mem limit: 64 MB    AC/Submission: 0/0    Discuss

      Back   Ranklist  Status  Pending: NaN天 NaN时 NaN分 NaN秒  
     

    Problem Description
    A famous ACMer named LIST.He is very rich,so he has infinite coins of some par value(面值).One day he has a list of things he want

    to buy.And he is so rich,he can buy a things for many ways.for example,if he want to spend 5 yuan to buy a things,he will give the seller five coins (1,1,1,1,1) or three coins (2,2,1) or two coins (3,2) and so on.Now he wants to ask you to help him calculate how many ways he can pay m yuan.



    Input
    In the first line is a number T means the amount of cases(T<=50).And in each case,the first line has two numbers ,n(the amount of the par value, n<=30) and m(the sum of money LIST has to spend, m<=150).

    In the next line has n numbers mean the different par value(each par value is no more than 35).



    Output
    Each case output one line,like"Case #i: Ai"(i is the number of case and Ai is the number of ways in this case).

    Ai might be big,but it can't be very big.



    Sample Input
    1
    5 13
    1 2 3 5 10


    Sample Output
    Case #1: 37


    Source
    分析:第一次敲的时候是多重背包,但是存在每一个硬币面额是没有限制的个数。最后小灰灰找到思路,说不是多重背包,是递归。最后服务器炸了,没有能提交上。

     1 #include<stdio.h>
     2 #include<stdlib.h>
     3 #include<string.h>
     4 int sum;
     5 int a[110];
     6 int b[110][110];
     7 int c[110] = { 0 };
     8 int max = 200;
     9 int m;
    10 void digui(int money, int n)
    11 {
    12     int j, k, flag = 0;
    13     if (money == 0)
    14     {
    15         sum++;
    16         return;
    17     }
    18     if (money <0)
    19     {
    20         return;
    21     }
    22     for (j = n;j >= 0;j--)
    23     {
    24         digui(money - a[j], j);
    25     }
    26 }
    27 int main(void)
    28 {
    29     int t, i, n, m, j;
    30     while (scanf("%d", &t) != EOF)
    31     {
    32         for (i = 0;i < t;i++)
    33         {
    34             sum = 0;
    35             scanf("%d%d", &n, &m);
    36             for (j = 0;j < n;j++)
    37             {
    38                 scanf("%d", &a[j]);
    39             }
    40             digui(m, n-1);
    41             printf("Case #%d:%d
    ",i+1, sum);
    42         }
    43     }
    44 }

    Problem: B

    Time limit: 1s    Mem limit: 64 MB    AC/Submission: 0/0    Discuss

      Back   Ranklist  Status  Pending: NaN天 NaN时 NaN分 NaN秒  
     

    Problem Description
    十滴水是一款益智小游戏。

    [图片链接在最下方]

    如上图所示,每一个方格内可能存在水滴或者为空,水滴的状态可能为1级水滴,2级水滴,3级水滴,4级水滴,你现在有若干1级水滴,当1级水滴滴在空白处,则空白处状态变为1级水滴,当1级水滴滴在其他水滴上时,使其等级+1,若水滴等级达到5以后会炸裂,向周围4个方向按照上左下右的顺序依次各发射一个1级水滴,1级水滴会沿着初始炸裂方向前进,直到遇到水滴(沿途不会在空白处停下),水滴出界则视为消失。

    现在有一个n*m的图,图中有若干等级已知的水滴,调皮的ACMER有k个1级水滴,将依次滴在相应的坐标,滴入第一滴后当图不再发生变化后滴入第二滴,以此类推,请你将最后的图的状态输出。

    当然,为了让水滴有序的炸裂,我们规定,当一滴水炸裂出的四个水滴的往上的那个水滴碰到水滴或者出界后,第二个水滴才会向左开始运动,以此类推。并且,当一滴水炸裂以后的水滴引起了新的水滴达到等级5,这个新的等级5的水滴会在刚才这个水滴的4个子水滴都出界或者遇到水滴以后再开始炸裂,并且四个子水滴引起的其他水滴的炸裂顺序按照上方的水滴引起的若干其他水滴的炸裂,然后再是左方水滴,以此类推,详细的请看提示。

    提示:

    如图是样例1的过程,红色加粗的水滴代表已经达到5级的水滴但还没爆裂,(为了方便……后面的图中#号不再表示)按照上述规定,水滴依次炸裂。(当这个水滴已经是五级水滴但还未炸裂时,如图中红色加粗的水滴,他们将被看做是空白区域)

    http://202.118.31.226/image/Hint.png



    Input
    输入有多组测试数据,在输入数据的第一行为测试数据组数T(1<=T<=20)。

    对于每一组测试数据,第一行为三个整数n,m,k,代表图的长,宽和水滴数量(3<=n,m<=32,1<=k<=10)

    接下来的n行,每行有m个字符,代表图的状态。(“#”字符代表边界)

    接下来的k行,每行两个元素,Xi,Yi,代表滴下水滴的坐标位置。(Xi是第i行,Yi是第i列,左上角的#是第0行第0列)



    Output
    对于第i组数据,第一行先输出”Case #i:”,然后接下来n行输出图的最终状态。每个样例之后空一行。



    Sample Input
    2
    5 6 1
    ######
    #2343#
    #2444#
    #2342#
    ######
    2 3
    6 6 2
    ######
    #0000#
    #4430#
    #1120#
    #0004#
    ######
    2 2
    4 4


    Sample Output
    Case #1:
    ######
    #4000#
    #4000#
    #4000#
    ######

    Case #2:
    ######
    #0000#
    #0000#
    #2230#
    #0000#
    ######


    Source



    Hint
    No Hint!

    这题是涂涂做的

     1 #include<stdio.h>
     2 #include<string.h>
     3 
     4 char maps[40][40];
     5 int movee[4][2]={{-1,0},{0,-1},{1,0},{0,1}};
     6 int k[15][2];
     7 int zhan[1600][2], head=0,tile=0;
     8 
     9 void zhan_pop(int x, int y)
    10 {
    11         zhan[tile][0] = x;
    12         zhan[tile][1] = y;
    13         tile ++;
    14         return;
    15 }
    16 
    17 int if_null()
    18 {
    19         if(head == tile) return 1;
    20         else return 0;
    21 }
    22 
    23 void pop_fwater(int x, int y)
    24 {
    25         if(maps[x][y] == '5') maps[x][y] ='0';
    26         zhan_pop(x,y);
    27         return;
    28 }
    29 
    30 void give_water(int x, int y, int s)
    31 {
    32         if(maps[x][y] == '0') {
    33                 give_water(x+movee[s][0], y+movee[s][1], s);
    34                 return;
    35         }
    36         else if(maps[x][y] == '#') return;
    37         else {
    38                 maps[x][y] ++;
    39                 if(maps[x][y] == '5') {
    40                         maps[x][y] = '0';
    41                         zhan_pop(x, y);
    42                 }
    43                 return;
    44         }
    45 }
    46 int main()
    47 {
    48         int a;
    49         while(scanf("%d", &a)!=EOF){
    50                 for(int i=0;i<a;i++){
    51                         int n, m, kk;
    52                         scanf("%d%d%d", &n, &m, &kk);
    53                         for(int x=0;x<n;x++){
    54                                 scanf("%s",maps[x]);
    55                         }
    56                         for(int x=0;x<kk;x++)scanf("%d%d", &k[x][0], &k[x][1]);
    57                         for(int x=0;x<kk;x++){
    58                                 int xx=k[x][0],yy=k[x][1];
    59                                 maps[xx][yy]++;
    60                                 if(maps[xx][yy] == '5') pop_fwater(xx,yy);
    61                                 while(!if_null()){
    62                                         xx=zhan[head][0];
    63                                         yy=zhan[head][1];
    64                                         for(int j=0;j<4;j++)
    65                                                 give_water(xx+movee[j][0], yy+movee[j][1], j);
    66                                         head++;
    67                                 }
    68                         }
    69                         printf("Case #%d:
    ", i+1);
    70                         for(int x=0;x<n;x++) printf("%s
    ", maps[x]);
    71                 }
    72         }
    73         return 0;
    74 }

    Problem: F

    Time limit: 1s    Mem limit: 64 MB    AC/Submission: 0/0    Discuss

      Back   Ranklist  Status  Pending: NaN天 NaN时 NaN分 NaN秒  
     

    Problem Description
    来来来,做道题,一起防老年痴呆。啤酒2元一瓶,4个瓶盖换一瓶,2个空瓶换一瓶。问:n元可换几瓶。不可以赊账不可以买半瓶酒.



    Input
    多组数据,输入文件第一行是一个整数T,接下来T行,每行一个整数n(0<=n<=10000000)



    Output
    问最多能够得到多少瓶啤酒



    Sample Input
    2
    0
    10


    Sample Output
    0
    15


    Source



    Hint
    No Hint!


    Submit
    思路:水题

     1 #include<stdio.h>
     2 
     3 int main()
     4 {
     5         int a;
     6         while(scanf("%d", &a)!=EOF){
     7                 for(int i=0;i<a;i++){
     8                         int n;
     9                         scanf("%d", &n);
    10                         n /= 2;
    11                         int ping=n,gai=n;
    12                         while(ping>=2 || gai>=4){
    13                                 int neww=0;
    14                                 neww += ping/2;
    15                                 neww += gai/4;
    16                                 ping = ping%2 +neww;
    17                                 gai = gai%4 +neww;
    18                                 n += neww;
    19                         }
    20                         printf("%d
    ",n);
    21                 }
    22         }
    23 
    24         return 0;
    25 }

    Problem: G

    Time limit: 1s    Mem limit: 835.3125 MB    AC/Submission: 0/0    Discuss

      Back   Ranklist  Status  Pending: NaN天 NaN时 NaN分 NaN秒  
     

    Problem Description
    有两个字符串,比如:abedc与acbde,它们公共的序列有许多种,这个序列在原串中可以是不连续的,比如ab,ad,abe,e等都可算做他们的公共序列,但是最长的序列为abe,长度为3,那么怎么求出这个序列最长是多少呢?



    Input
    第一行是一个整数T,代表多少组数据(T<=15)

    每组数据给出两个字符串(由小写字符组成),长度都小于5000



    Output
    按题意输出一个整数



    Sample Input
    2
    abcde
    edcba
    abedc
    acbde


    Sample Output
    1
    3


    Source



    Hint
    No Hint!
    思路:求最长公共子序列长度

     1 #include <iostream>
     2 #include<cstring>
     3 #include<cstdio>
     4 using namespace std;
     5 int dp[1001][1001];
     6 char s1[1001],s2[1001];
     7 
     8 int LCS(int len1,int len2)
     9 {
    10     memset(dp,0,sizeof(dp));
    11     for(int i=1;i<=len1;i++)
    12         for(int j=1;j<=len2;j++)
    13     {
    14         if(s1[i-1]==s2[j-1])
    15             dp[i][j]=dp[i-1][j-1]+1;
    16         else
    17         dp[i][j]=dp[i-1][j]>dp[i][j-1]?dp[i-1][j]:dp[i][j-1];
    18     }
    19     return dp[len1][len2];
    20 }
    21 int main()
    22 {
    23     int len1,len2;
    24     int T;
    25     scanf("%d",&T);
    26     while(T--)
    27     {
    28     scanf("%s%s",s1,s2);
    29     {
    30         len1=strlen(s1);
    31         len2=strlen(s2);
    32         printf("%d
    ",LCS(len1,len2));
    33      }
    34     }
    35     return 0;
    36 }

    一共做出4道题,提交AC了3道,一道服务器在还有半个小时时候已经挂了,没法提交。

  • 相关阅读:
    racktable安装过程
    racktables
    EM上的按钮是方框的问题
    install oracle
    记一次ORACLE无法启动登陆事故
    安装rlwrap-0.37.tar.gz
    centos7 安装oracle 11g数据库
    centos 7 安装mariadb
    centos7 lamp
    Linux安全之SSH 密钥创建及密钥登录
  • 原文地址:https://www.cnblogs.com/chengxs/p/5428496.html
Copyright © 2011-2022 走看看