LSNU_ACM三月月赛小组总结

题目链接:https://vjudge.net/contest/290592

前言:

从比赛题目上看,三月月赛的题目难度不是很大,主要包含数学、大数加法(高精度)、简单DP(C、D题除外);

从比赛结果上看,我们小组通过了7/10的题,其中I题用的Java大数处理,E题是之前比赛做过的原题(水题);

从比赛过程中看,我们小组经过7个月的磨合,每个人都配合的很好,分工明确,比如有时候我们一起讨论出一个题并有大体思路时,凯文就写代码,丹姐在旁边检查,而我就去寻觅下一个能解的题;有时候也会交换敲代码,说实话,我很喜欢这样小组一起看题、一起解题、一起讨论的感觉。

A题-Dick and Jane(ZOJ 1110)

Dick is 12 years old. When we say this, we mean that it is at least twelve and not yet thirteen years since Dick was born.

Dick and Jane have three pets: Spot the dog, Puff the Cat, and Yertle the Turtle. Spot was s years old when Puff was born; Puff was p years old when Yertle was born; Spot was y years old when Yertle was born. The sum of Spot's age, Puff's age, and Yertle's age equals the sum of Dick's age (d) and Jane's age (j). How old are Spot, Puff, and Yertle?

Each input line contains four non-negative integers: s, p, y, j. For each input line, print a line containing three integers: Spot's age, Puff's age, and Yertle's age. Ages are given in years, as described in the first paragraph.

Sample Input

5 5 10 9
5 5 10 10
5 5 11 10

Output for Sample Input

12 7 2
13 7 2
13 7 2

转载:http://blog.sina.com.cn/s/blog_d0fededb0101f67s.html

 B题-Let the Balloon Rise(ZOJ 2104)

Contest time again! How excited it is to see balloons floating around. But to tell you a secret, the judges' favorite time is guessing the most popular problem. When the contest is over, they will count the balloons of each color and find the result.
This year, they decide to leave this lovely job to you.

Input
Input contains multiple test cases. Each test case starts with a number N (0 < N < 1000) -- the total number of balloons distributed. The next N lines contain one color each. The color of a balloon is a string of up to 15 lower-case letters.
A test case with N = 0 terminates the input and this test case is not to be processed.

Output
For each case, print the color of balloon for the most popular problem on a single line. It is guaranteed that there is a unique solution for each test case.

Sample Input
5
green
red
blue
red
red
3
pink
orange
pink
0

Sample Output
red
pink

题目分析:

B题的题意很简单,就是求出现次数最多的一种颜色(字符串),我们第一想法就是用结构体数组来做,其中包括一个字符数组来存输入的字符串,一个int变量实时存储出现的次数。

每输入一个字符串就存储下来,并与之前所有已存的字符串作比较,一旦找到相同的串,其num++且跳出for循环;所有数据输入结束后用sort函数对结构体数组中num值进行从大到小排序,排完序后第一个数组中的字符串就是出现次数最多的。

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
struct f{
  char name[30];
  int num;
}x[1005];
bool cmp(struct f x,struct f y)
{
    return x.num>y.num;
}
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        if(n==0)
            break;
        for(int i=0;i<n;i++)
            x[i].num=0;
        for(int i=0;i<n;i++){
            scanf("%s",x[i].name);
            int tag=0;   //tag的作用主要是用于存储第一个字符串
            for(int j=0;j<i;j++){
                if(strcmp(x[i].name,x[j].name)==0){
                    x[j].num++;
                    tag=1;
                    break;
                }
            }
            if(!tag)
                x[i].num=1;
        }
        sort(x,x+n,cmp);
        printf("%s\n",x[0].name);
    }
    return 0;
}

E题 - Keep on Truckin'(HDU 1037)

Boudreaux and Thibodeaux are on the road again . . . 
"Boudreaux, we have to get this shipment of mudbugs to Baton Rouge by tonight!" 
"Don't worry, Thibodeaux, I already checked ahead. There are three underpasses and our 18-wheeler will fit through all of them, so just keep that motor running!" 
"We're not going to make it, I say!" 
So, which is it: will there be a very messy accident on Interstate 10, or is Thibodeaux just letting the sound of his own wheels drive him crazy? 

Input

Input to this problem will consist of a single data set. The data set will be formatted according to the following description. 
The data set will consist of a single line containing 3 numbers, separated by single spaces. Each number represents the height of a single underpass in inches. Each number will be between 0 and 300 inclusive. 

Output

There will be exactly one line of output. This line will be: 
   NO CRASH 
if the height of the 18-wheeler is less than the height of each of the underpasses, or: 
   CRASH X 
otherwise, where X is the height of the first underpass in the data set that the 18-wheeler is unable to go under (which means its height is less than or equal to the height of the 18-wheeler). 
The height of the 18-wheeler is 168 inches. 

Sample Input

180 160 170

Sample Output

CRASH 160

题目分析:

水题,只要把题意理解清楚就可以了,题意大致是,输入三个数,如果三个数全部都大于168,则输出“NO CRASH ”,如果小于等于168,则输出“CRASH +该数”。

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
        int a[3];
        int flag = 0;
        scanf("%d%d%d", &a[0], &a[1], &a[2]);
        for(int i = 0; i <3; ++i){
            if(a[i] <= 168){
                printf("CRASH %d\n", a[i]);
                flag = 1;
            }
        }
        if(!flag)
            printf("NO CRASH\n");

    return 0;
}

 

F题-Climbing Worm(HDU 1049)

An inch worm is at the bottom of a well n inches deep. It has enough energy to climb u inches every minute, but then has to rest a minute before climbing again. During the rest, it slips down d inches. The process of climbing and resting then repeats. How long before the worm climbs out of the well? We'll always count a portion of a minute as a whole minute and if the worm just reaches the top of the well at the end of its climbing, we'll assume the worm makes it out. 

Input

There will be multiple problem instances. Each line will contain 3 positive integers n, u and d. These give the values mentioned in the paragraph above. Furthermore, you may assume d < u and n < 100. A value of n = 0 indicates end of output. 

Output

Each input instance should generate a single integer on a line, indicating the number of minutes it takes for the worm to climb out of the well. 

Sample Input

10 2 1
20 3 1
0 0 0

Sample Output

17
19

题目分析:

简单题,题意大致是,深度为n的井底有一只虫,向上爬u需要1分钟,每次向上爬完都要休息1分钟,休息期间下滑d,求该虫爬出井需要多长时间。

#include<cstdio>
using namespace std;
int main()
{
    int n,u,d;
    while(~scanf("%d %d %d",&n,&u,&d)){
        if(n==0 && u==0 && d==0)
            break;
        else{
           int tag=0;
           int num=0;
           while(n>0){
               if(tag==0) {
                   n-=u;
                   tag=1;
               }
               else{
                   n+=d;
                   tag=0;
               }
               num++;
           }
           printf("%d\n",num);
        }
    }
    return 0;
}

G题 - Tiling_easy version(HDU 2501)

有一个大小是 2 x n 的网格,现在需要用2种规格的骨牌铺满,骨牌规格分别是 2 x 1 和 2 x 2,请计算一共有多少种铺设的方法。 

Input

输入的第一行包含一个正整数T(T<=20),表示一共有 T组数据,接着是T行数据,每行包含一个正整数N(N<=30),表示网格的大小是2行N列。 

Output

输出一共有多少种铺设的方法,每组数据的输出占一行。 

Sample Input

3
2
8
12

Sample Output

3
171
2731

题目分析: 

递推题,现有两种骨牌,N为1时答案为1,N为2是答案为3;从N=3开始,先考虑后边,如果最后放2*1的骨牌,那么有a[n-1]种放法;如果最后放2*2的骨牌,有可能放两个横着的2*1的骨牌,也有可能是一个2*2的骨牌,所以共有2*a[n-2]种放法,故递推式为a[n]=a[n-1]+2*a[n-2]。

#include<cstdio>
using namespace std;
int a[100];
void init()
{
    a[1]=1;
    a[2]=3;
    for(int i =3;i<35;i++)
        a[i] = a[i-1]+a[i-2]*2;
}
int main()
{
    int n;
    init();
    scanf("%d",&n);
    while(n--){
        int x;
        scanf("%d",&x);
        printf("%d\n",a[x]);
    }
    return 0;
}

H题 - Least Common Multiple(ZOJ 1797)

The least common multiple (LCM) of a set of positive integers is the smallest positive integer which is divisible by all the numbers in the set. For example, the LCM of 5, 7 and 15 is 105.

Input

Input will consist of multiple problem instances. The first line of the input will contain a single integer indicating the number of problem instances. Each instance will consist of a single line of the form m n1 n2 n3 ... nm where m is the number of integers in the set and n1 ... nm are the integers. All integers will be positive and lie within the range of a 32-bit integer.

Output

For each problem instance, output a single line containing the corresponding LCM. All results will lie in the range of a 32-bit integer.

Sample Input

2
3 5 7 15
6 4 10296 936 1287 792 1

Sample Output

105
10296

题目分析:

这个题主要是对最小公倍数的应用,题意是求所有数的最小公倍数。

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int a[100000];
int f(int x, int y)
{
    int t;

    if(x < y){
        t = x;
        x = y;
        y = t;
    }
    int b = y;
    int a = x;
    while(x % y){
        int temp = x % y;
        x = y;
        y = temp;
    }
    return a / y * b;

}
int main()
{
   int n;
   scanf("%d",&n);
   while(n--){
    int t;
    scanf("%d",&t);
    for(int i =0;i<t;i++)
        scanf("%d",&a[i]);

    int res = a[0];
    for(int i = 1;i < t;i++)
        res = f(res, a[i]);

    printf("%d\n", res);
   }
    return 0;
}

I题 - 大明A+B(HDU 1753)

话说,经过了漫长的一个多月,小明已经成长了许多,所以他改了一个名字叫“大明”。 
这时他已经不是那个只会做100以内加法的那个“小明”了,现在他甚至会任意长度的正小数的加法。 
现在,给你两个正的小数A和B,你的任务是代表大明计算出A+B的值。 

Input

本题目包含多组测试数据,请处理到文件结束。 
每一组测试数据在一行里面包含两个长度不大于400的正小数A和B。

Output

请在一行里面输出输出A+B的值,请输出最简形式。详细要求请见Sample Output。 

Sample Input

1.1 2.9
1.1111111111 2.3444323343
1 1.1

Sample Output

4
3.4555434454
2.1

题目分析: 

这个题题意很简单,就是两个数求和,但是存在以下问题:1、数的位数最长可达到400位;2、答案要最简(无多余的后缀0和小数点)。我们的第一想法就是用Java中的大数来处理,但是答案最简还需要做处理(转化为字符数组,从后向前找到第一个不为0、不为‘.’的位数并标记,最后从前往后输出字符串)。这个题我们W了三次,主要是情况没有考虑完全。

其实对于后缀的处理,Java中方法解决,只是我们之前不知道而已,如下:

 System.out.println(a.add(b).stripTrailingZeros().toPlainString());
import java.math.BigDecimal;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			BigDecimal a = sc.nextBigDecimal();
			BigDecimal b = sc.nextBigDecimal();
			BigDecimal c = a.add(b);
			String s = String.valueOf(c);
			if("0".equals(s)){
				System.out.println(0);
				continue;
			}
			if(s.endsWith("0")&& s.contains(".")){
				char x[] = s.toCharArray();
				int len = x.length -1;
				
				while(x[len - 1] == '0'){
					len--;
				}
				
				if(x[len - 1] == '.')
					len--;
				for(int i = 0; i < len; ++i){	
					System.out.printf("%c", x[i]);
				}
				System.out.println();
			}
			else{
				System.out.println(s);
			}

		}

	}

}

J题 - MagicBuilding(HDU 2192)

As the increase of population, the living space for people is becoming smaller and smaller. In MagicStar the problem is much worse. Dr. Mathematica is trying to save land by clustering buildings and then we call the set of buildings MagicBuilding. Now we can treat the buildings as a square of size d, and the height doesn't matter. Buildings of d1,d2,d3....dn can be clustered into one MagicBuilding if they satisfy di != dj(i != j). 
Given a series of buildings size , you need to calculate the minimal numbers of MagicBuildings that can be made. Note that one building can also be considered as a MagicBuilding. 
Suppose there are five buildings : 1, 2, 2, 3, 3. We make three MagicBuildings (1,3), (2,3), (2) .And we can also make two MagicBuilding :(1,2,3), (2,3). There is at least two MagicBuildings obviously.

Input

The first line of the input is a single number t, indicating the number of test cases. 
Each test case starts by n (1≤n≤10^4) in a line indicating the number of buildings. Next n positive numbers (less than 2^31) will be the size of the buildings.

Output

For each test case , output a number perline, meaning the minimal number of the MagicBuilding that can be made.

Sample Input

2
1
2 
5
1 2 2 3 3

Sample Output

1
2

题目分析: 

本题的意思大致是输入n个数,把这些数分成尽可能少的组,分组的唯一条件就是“每组中不能有相同的数存在”,求那一种分法中的组数最少。

这个题我们最开始的想法是,将每个数出现的次数计算出来,每一次将每个数减一,sum++,直到出现次数最少的那个数减为0,那么此时的sum就是所求的答案;但是有个问题是,n的取值可以达到10的4次方,计算次数+遍历完后应该会超时;

然后我们又想到用数组标记法,输入的时候就记录每个数的次数,但是在后面遍历(双for)还是会超时;

最后,我们发现这个题有规律,每一次的答案都是出现最多的数的次数,我们想到的是用数组存入数据,sort排序,这样保证相同的数排在一起,之后用sum记录每个相同数出现的次数,Max记录最大值,Max即是答案。

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

int main()
{
    int n;
    scanf("%d", &n);
    while(n--){
        int a[10010];
        int m;

        scanf("%d", &m);

        for(int i = 0;i < m; ++i)
            scanf("%d", &a[i]);

        sort(a, a + m);
        int Max = 1;
        int sum = 1;
        for(int i = 0; i < m - 1; ++i){
            if(a[i] == a[i + 1])
                sum++;
            else{
                if(sum > Max)
                    Max = sum;
                sum = 1;
            }
        }
        if(sum > Max)
            Max =sum;

        printf("%d\n", Max);
    }
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
东南亚位于我国倡导推进的“一带一路”海陆交汇地带,作为当今全球发展最为迅速的地区之一,近年来区域内生产总值实现了显著且稳定的增长。根据东盟主要经济体公布的最新数据,印度尼西亚2023年国内生产总值(GDP)增长5.05%;越南2023年经济增长5.05%;马来西亚2023年经济增速为3.7%;泰国2023年经济增长1.9%;新加坡2023年经济增长1.1%;柬埔寨2023年经济增速预计为5.6%。 东盟国家在“一带一路”沿线国家中的总体GDP经济规模、贸易总额与国外直接投资均为最大,因此有着举足轻重的地位和作用。当前,东盟与中国已互相成为双方最大的交易伙伴。中国-东盟贸易总额已从2013年的443亿元增长至 2023年合计超逾6.4万亿元,占中国外贸总值的15.4%。在过去20余年中,东盟国家不断在全球多变的格局里面临挑战并寻求机遇。2023东盟国家主要经济体受到国内消费、国外投资、货币政策、旅游业复苏、和大宗商品出口价企稳等方面的提振,经济显现出稳步增长态势和强韧性的潜能。 本调研报告旨在深度挖掘东南亚市场的增长潜力与发展机会,分析东南亚市场竞争态势、销售模式、客户偏好、整体市场营商环境,为国内企业出海开展业务提供客观参考意见。 本文核心内容: 市场空间:全球行业市场空间、东南亚市场发展空间。 竞争态势:全球份额,东南亚市场企业份额。 销售模式:东南亚市场销售模式、本地代理商 客户情况:东南亚本地客户及偏好分析 营商环境:东南亚营商环境分析 本文纳入的企业包括国外及印尼本土企业,以及相关上下游企业等,部分名单 QYResearch是全球知名的大型咨询公司,行业涵盖各高科技行业产业链细分市场,横跨如半导体产业链(半导体设备及零部件、半导体材料、集成电路、制造、封测、分立器件、传感器、光电器件)、光伏产业链(设备、硅料/硅片、电池片、组件、辅料支架、逆变器、电站终端)、新能源汽车产业链(动力电池及材料、电驱电控、汽车半导体/电子、整车、充电桩)、通信产业链(通信系统设备、终端设备、电子元器件、射频前端、光模块、4G/5G/6G、宽带、IoT、数字经济、AI)、先进材料产业链(金属材料、高分子材料、陶瓷材料、纳米材料等)、机械制造产业链(数控机床、工程机械、电气机械、3C自动化、工业机器人、激光、工控、无人机)、食品药品、医疗器械、农业等。邮箱:market@qyresearch.com

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值