河南省第九届大学生程序设计竞赛(未完待续)

本文精选了河南省第九届大学生程序设计竞赛中的六道题目,包括表达式求值、宣传墙张贴方案计数、信道安全分析、导弹发射路径优化、机器设备传动分析及数值转换错误纠正等,详细介绍了各题目的背景、输入输出要求与样例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1923: 表达式求值

Time Limit: 1 Sec   Memory Limit: 128 MB
Submit: 42   Solved: 8

Submit Status Web Board

Description

假设表达式定义为:
1. 一个十进制的正整数 X 是一个表达式。
2. 如果 X 和 Y 是 表达式,则 X+Y, X*Y 也是表达式; *优先级高于+.
3. 如果 X 和 Y 是 表达式,则 函数 Smax(X,Y)也是表达式,其值为:先分别求出 X ,Y
值的各位数字之和,再从中选最大数。
4.如果 X 是 表达式,则 (X)也是表达式。
例如:
表达式 12*(2+3)+Smax(333,220+280) 的值为 69。
请你编程,对给定的表达式,输出其值。

Input

第一行: T 表示要计算的表达式个数 ( 1T10 1≤T≤10
接下来有 T 行, 每行是一个字符串,表示待求的表达式,长度<=1000

Output

对于每个表达式,输出一行,表示对应表达式的值。

Sample Input

312+2*312*(2+3)12*(2+3)+Smax(333,220+280)

Sample Output

186069

HINT

Source

河南省第九届大学生程序设计竞赛



1924: 宣传墙

Time Limit: 1 Sec   Memory Limit: 128 MB
Submit: 16   Solved: 3

Submit Status Web Board

Description

ALPHA 小镇风景美丽,道路整齐,干净,到此旅游的游客特别多。CBA 镇长准备在一条道路南
面 4*N 的墙上做一系列的宣传。为了统一规划,CBA 镇长要求每个宣传栏只能占相邻的两个方格
位置。但这条道路被另一条道路分割成左右两段。CBA 镇长想知道,若每个位置都贴上宣传栏,
左右两段各有有多少种不同的张贴方案。
例如:
N=6,M=3, K=2, 左,右边各有 5 种不同的张贴方案

Input

第一行: T 表示以下有 T 组测试数据 ( 1≤T ≤8 )
接下来有T行, 每行三个正整数 N M K 分别表示道路的长度,另一条道路的起点和宽度
(1≤ N ,M ≤ 1 000 000, 1≤ K ≤ 100000)

Output

每组测试数据,输出占一行:两个整数,分别表示左右两段不同的张贴方案数。由于方案总数
可能很大,请输出对 997 取模后的结果。

Sample Input

26 3 25 3 2

Sample Output

5 55 1

HINT

Source




1925: 信道安全

Time Limit: 2 Sec   Memory Limit: 128 MB
Submit: 168   Solved: 30

Submit Status Web Board

Description

Alpha 机构有自己的一套网络系统进行信息传送。情报员 A 位于节点 1,他准备将一份情报
发送给位于节点 n 的情报部门。可是由于最近国际纷争,战事不断,很多信道都有可能被遭到监
视或破坏。
经过测试分析,Alpha 情报系统获得了网络中每段信道安全可靠性的概率,情报员 A 决定选
择一条安全性最高,即概率最大的信道路径进行发送情报。
你能帮情报员 A 找到这条信道路径吗?

Input

第一行: T 表示以下有 T 组测试数据 ( 1≤T ≤8 )
对每组测试数据:
第一行: n m  分别表示网络中的节点数和信道数 (1<=n<=10000,1<=m<=50000)
接下来有 m 行, 每行包含三个整数 i,j,p,表示节点 i 与节点 j 之间有一条信道,其信
道安全可靠性的概率为 p%。 ( 1<=i, j<=n 1<=p<=100)

Output

每组测试数据,输出占一行,一个实数 即情报传送到达节点 n 的最高概率,精确到小数点后
6 位。

Sample Input

15 75 2 1003 5 802 3 702 1 503 4 904 1 853 1 70

Sample Output

61.200000

HINT

Source

河南省第九届大学程序设计竞赛


1926: 导弹发射

Time Limit: 1 Sec   Memory Limit: 128 MB
Submit: 54   Solved: 1

Submit Status Web Board

Description

Alpha 机构研发出一种新型智能导弹,它能够在雷达检测到的区域内,选择一条前进的路径,
击破路径上所有的目标物。
雷达位于(0,0)处,它能够检测到两条射线之间的区域(不妨设在第一象限)。
导弹一开始置放在(0,0)处,它可以在雷达能检测到的区域内先选择一个目标物击破,然后
再继续前进,选择另一个目标物击破。注意,导弹不能沿着这两条射线前进,当然也不能停在原
地。
可以假设,导弹一旦发射,其能量无比大,前进的路径无限长。
已知雷达能够检测到区域,其射线 1:ax-by=0 和射线 2:cx-dy=0。Alpha 机构的总指挥希望
在发现目标群的第一时刻,计算出一条可以击破最多目标物的路径。

Input

第一行: T 表示以下有 T 组测试数据(1≤T ≤8)
对每组测试数据:
第 1 行: n 表示目标物的个数
第 2 行: a b c d 代表两条射线的斜率分别是 a/b 和 c/d。
接下来有 n 行,每行 2 个正整数 xi yi 即第 i 个目标物的坐标。
(1) n<=10^5 0<=a, b, c, d<=10^5 a 和 b 不会同时为 0,c 和 d 不会同时为 0;
(2) 0<= xi , yi <=10^6 i=1,…..,n

Output

每组测试数据,输出占一行,即导弹能击破的最多目标数。

Sample Input

1151 3 2 13 16 24 22 54 56 63 41 62 17 49 35 31 315 512 4

Sample Output

4

HINT

Source


1927: 机器设备

Time Limit: 1 Sec   Memory Limit: 128 MB
Submit: 39   Solved: 8

Submit Status Web Board

Description

Alpha 公司设计出一种节能的机器设备。它的内部结构是由 N 个齿轮组成。整个机器设备有
一个驱动齿轮,当启动它时,它立即按 10,000 圈/小时转速顺时针转动,然后它又带动与它相切
的齿轮反方向,即逆时针转动。齿轮之间互相作用,每个齿轮都可能驱动着多个齿轮,最终带动
一个工作齿轮完成相应的任务 。
在这套设备中,记录了每个齿轮的圆心坐标和齿轮半径。已知驱动齿轮位于(0,0),最终的
工作齿轮位于(Xt, Yt)。
Alpha 公司想知道传动序列中所有齿轮的转速。所谓传动序列,即能量由驱动齿轮传送,最
后到达工作齿轮的过程中用到的所有齿轮。能量传送过程是,在一个半径为 R,转速为 S 圈/每小
时的齿轮的带动下,与它相切的半径为 R’的齿轮的转速为-S*R/R` 转/小时。负号的意思是, 表
示按反方向转动。
已知,机器设备中除了驱动齿轮以外,所有齿轮都可能被另外某个齿轮带动,并且不会出现
2 个不同的齿轮带动同一个齿轮的情况。
你的任务是计算整个传动序列中所有齿轮的能量之和。即所有齿轮转速的绝对值之和。

Input

第一行: T 表示以下有 T 组测试数据(1≤T ≤8)
对每组测试数据:
第 1 行: N Xt Yt (2≤N ≤1100)
接下来有 N 行, Xi Yi Ri 表示 N 个齿轮的坐标和半径 i=1,2,….,N
( -5000 ≤Xi ,Yi ≤ 5000 3 ≤ Ri ≤ 1000 )

Output

第一行: T 表示以下有 T 组测试数据(1≤T ≤8)
对每组测试数据:
第 1 行: N Xt Yt (2≤N ≤1100)
接下来有 N 行, Xi Yi Ri 表示 N 个齿轮的坐标和半径 i=1,2,….,N
( -5000 ≤Xi ,Yi ≤ 5000 3 ≤ Ri ≤ 1000 )

Sample Input

14 32 540 30 200 0 1032 54 20-40 30 20

Sample Output

20000

HINT

Source

河南省第九届大学生程序设计竞赛


#include <stdio.h>  
#include <math.h>  
struct Node  
{  
    int x,y,r;//横纵坐标和半径   
    double w;//转速   
    int mark;//标记   
}s[1100];  
int N,star,end,flag;  
void DFS(int k,double sum)  
{  
    if(flag==1)//剪枝   
        return ;  
    if(k==end)//找到最后的终端齿轮   
    {  
        printf("%d\n",(int)sum);  
        flag=1;   
        return ;  
    }     
    for(int i=0;i<N;i++)//从N个齿轮中找与之相切的   
    {  
        if(s[i].x==s[k].x && s[i].y==s[k].y || s[i].mark==1)//判断是不是本身或者是已经找过的   
            continue;  
        double R2=pow((s[i].x-s[k].x),2)+pow((s[i].y-s[k].y),2);  
        if(R2==pow((s[i].r+s[k].r),2) && s[i].mark==0)//判断是否相切   
        {  
            s[i].mark=1;//标记已经找过   
            s[i].w=s[k].w*s[k].r/s[i].r;//计算转速   
            sum+=s[i].w;//计算转速和   
            DFS(i,sum);//继续搜索下一个   
            s[i].mark=0;//如果搜索失败,则返回上一层,取消标价   
            sum-=s[i].w;//减去之前不满足的齿轮的转速   
        }  
    }  
}  
int main()  
{  
    int T,x0,y0,i;  
    scanf("%d",&T);  
    while(T--)  
    {  
        scanf("%d%d%d",&N,&x0,&y0);  
        for(i=0;i<N;i++)  
        {  
            scanf("%d%d%d",&s[i].x,&s[i].y,&s[i].r);  
            s[i].mark=0;//所有齿轮标记的初始化   
            if(s[i].x==0 && s[i].y==0)  
                star=i,s[star].w=10000;//动力齿轮   
            if(s[i].x==x0 && s[i].y==y0)  
                end=i;//最后的终端齿轮   
        }  
        s[star].mark=1; flag=0;//将第一个动力齿轮标记为已经找过   
        DFS(star,s[star].w);  
    }  
    return 0;  
}  




1928: Decimal integer conversion

Time Limit: 1 Sec   Memory Limit: 128 MB
Submit: 40   Solved: 16

Submit Status Web Board

Description

XiaoMing likes mathematics, and he is just learning how to convert numbers between different
bases , but he keeps making errors since he is only 6 years old. Whenever XiaoMing converts a
number to a new base and writes down the result, he always writes one of the digits wrong.
For example , if he converts the number 14 into binary (i.e., base 2), the correct result should be
"1110", but he might instead write down "0110" or "1111". XiaoMing never accidentally adds or
deletes digits, so he might write down a number with a leading digit of " 0" if this is the digit she
gets wrong.
Given XiaoMing 's output when converting a number N into base 2 and base 3, please determine
the correct original value of N (in base 10). (N<=10^10)
You can assume N is at most 1 billion, and that there is a unique solution for N.

Input

The first line of the input contains one integers T, which is the nember of test cases (1<=T<=8)
Each test case specifies:
* Line 1: The base-2 representation of N , with one digit written incorrectly.
* Line 2: The base-3 representation of N , with one digit written incorrectly.

Output

For each test case generate a single line containing a single integer ,  the correct value of N

Sample Input

11010212

Sample Output

14

HINT

Source

河南省第九届大学生程序设计竞赛


解题思路:直接套用两层循环,对每一位都进行一次错误的尝试,然后计算结果存起来,最后得到一个二进制的 错误数组,和一个三进制的错误数据,然后寻找其中相同的值就行了


#include <stdio.h>  
#include <string.h>  
#include <math.h>  
int a[50];//二进制错误数组   
int b[105];//二进制错误数组  
char s1[50];//二进制字符串   
char s2[50];//三进制字符串   
int main()  
{  
    int T,i,j,k;  
    scanf("%d",&T);  
    getchar();  
    while(T--)  
    {  
        gets(s1);  
        gets(s2);  
        int len1=strlen(s1);  
        int len2=strlen(s2);  
        memset(a,0,sizeof(a));  
        memset(b,0,sizeof(b));  
        for(i=0;i<len1;i++)  
        {  
            s1[i]=(s1[i]-'0'+1)%2+'0';//对进制取错位   
            for(j=0;j<len1;j++)  
                a[i]+=(s1[j]-'0')*(int)pow(2,len1-1-j);  
            s1[i]=(s1[i]-'0'+1)%2+'0';//还原进制字符串,确保每次只有一位错误   
        }  
        for(i=0,k=0;i<len2;i++)  
        {  
            s2[i]=(s2[i]-'0'+1)%3+'0';//原理同二进制中的代码   
            for(j=0;j<len2;j++)  
                b[k]+=(s2[j]-'0')*(int)pow(3,len2-1-j);  
            k++;  
            s2[i]=(s2[i]-'0'+1)%3+'0';//每次累加 1 取错位   
            for(j=0;j<len2;j++)  
                b[k]+=(s2[j]-'0')*(int)pow(3,len2-1-j);  
            k++;  
            s2[i]=(s2[i]-'0'+1)%3+'0';//还原   
        }  
        for(i=0;i<len1;i++)  
            for(j=0;j<k;j++)  
                if(a[i]==b[j])  
                {  
                    printf("%d\n",a[i]);  
                    break;  
                }  
    }  
    return 0;  
}  




1929: Prototypes analyze

Time Limit: 1 Sec   Memory Limit: 128 MB
Submit: 6   Solved: 2

Submit Status Web Board

Description

ALpha Ceiling Manufacturers (ACM) is analyzing the p roperties of its new series of Incredibly
Collapse-Proof Ceilings (ICPCs). An ICPC consists of n layers of material, each with a different
value of collapse resistance (measured as a positive integer). The analysis ACM wants to run will
take the collapse-resistance values of the layers, store them in a binary search tree, and check
whether the shape of this tree in any way correlates with the quality of the whole construction.
Because, well, why should it not?
To be precise, ACM takes the collapse-resistance values for the layers, ordered from the top layer
to the bottom layer, and inserts them one-by-one into a tree. The rules for inserting a value v are:
• If the tree is empty, make v the root of the tree.
• If the tree is not empty, compare v with the root of the tree. If v is smaller, insert v into the left
subtree of the root, otherwise insert v into the right subtree.
ACM has a set of ceiling prototypes it wants to analyze by trying to collapse them. It wants to take
each group of ceiling prototypes that have trees of the same shape and analyze them together.
For example , assume ACM is considering five ceiling prototypes with three layers each, as
described by Sample Input 1 and shown in Figure C.1. Notice that the first prototype’s top layer
has collapseresistance value 2, the middle layer has value 7, and the bottom layer has value 1. The
second prototype has layers with collapse-resistance values of 3, 1, and 4 – and yet these two
prototypes induce the same tree shape, so ACM will analyze them together.
Given a set of prototypes, your task is to determine how many different tree shapes they induce.

Input

The first line of the input contains one integers T, which is the nember of test cases (1<=T<=8).
Each test case specifies:
* Line 1: two integers n (1 ≤ n ≤ 50), which is the number of ceiling prototypes to analyze,
and k (1  ≤  k ≤  20), which is the number of layers in each of the prototypes.
*T he next n lines describe the ceiling prototypes. Each of these lines contains k distinct
integers ( between 1 and 10 6 , inclusive ) , which are the collapse-resistance values of the
layers in a ceiling prototype, ordered from top to bottom.

Output

For each test case generate a single line containing a single integer that is the number of different tree
shapes.

Sample Input

15 32 7 11 5 93 1 42 6 59 7 3

Sample Output

4

HINT

Source



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值