| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1901 人关注过本帖
标题:[讨论]第十六期编程题目
只看楼主 加入收藏
leeco
Rank: 4
等 级:贵宾
威 望:10
帖 子:1029
专家分:177
注 册:2007-5-10
结帖率:50%
收藏
 问题点数:0 回复次数:18 
[讨论]第十六期编程题目

crackerwang说这次由我出题,鉴于各位大多没学过数据结构和算法,我就选了两道不需要算法和数据结构的题。大家可以在线测试一下自己的代码,再把代码发上来。
原题地址:
http://acm.fzu.edu.cn/problem.php?pid=1505
注册地址:
http://acm.fzu.edu.cn/reg.php
提交地址:
http://acm.fzu.edu.cn/submit.php?pid=1505

这题比较简单,不需要任何算法。大家踊跃尝试
Minimum value

时限:1秒 内存:32M
通过:50 提交:117

An arithmetic expression is defined as a sequence of positive integers, separated by arithmetic operators: +,-,(,). Given an arithmetic expression without parentheses, you are to calculate the minimum possible value for the expression, by adding appropriate parentheses to the expression.
Input
The input contains several test cases. Each test case is a single line containing a expression.
The expression consists of only positive integers,+,-
Numbers in expression may contain leading zeroes and is within 32bit integer, the total length of the expression will not exceed 100.
Output
For each case, output an integer representing the minimum value of the expression.
Sample input
00009-00009
10+20+30+40
1-4+6
Sample output
0
100
-9

题目大意,给定一个不含括号的加减表达式,你可以为它任意添加括号,输出这个表达式在添加括号后可能达到的最小值。
例如1-4+6 可以添加成为1-(4+6)=-9

第二题原题地址:
http://acm.pku.edu.cn/JudgeOnline/problem?id=3213
注册地址:
http://acm.pku.edu.cn/JudgeOnline/register
提交地址:
http://acm.pku.edu.cn/JudgeOnline/submit?problem_id=3213

这题也不需要算法,但需要一点关于矩阵运算的知识
PM3
Time Limit:5000MS Memory Limit:131072K
Total Submit:1532 Accepted:380
Description
USTC has recently developed the Parallel Matrix Multiplication Machine – PM3, which is used for very large matrix multiplication.
Given two matrices A and B, where A is an N × P matrix and B is a P × M matrix, PM3 can compute matrix C = AB in O(P(N + P + M)) time. However the developers of PM3 soon discovered a small problem: there is a small chance that PM3 makes a mistake, and whenever a mistake occurs, the resultant matrix C will contain exactly one incorrect element.
The developers come up with a natural remedy. After PM3 gives the matrix C, they check and correct it. They think it is a simple task, because there will be at most one incorrect element.
So you are to write a program to check and correct the result computed by PM3.
Input
The first line of the input three integers N, P and M (0 < N, P, M ≤ 1,000), which indicate the dimensions of A and B. Then follow N lines with P integers each, giving the elements of A in row-major order. After that the elements of B and C are given in the same manner.
Elements of A and B are bounded by 1,000 in absolute values which those of C are bounded by 2,000,000,000.
Output
If C contains no incorrect element, print “Yes”. Otherwise print “No” followed by two more lines, with two integers r and c on the first one, and another integer v on the second one, which indicates the element of C at row r, column c should be corrected to v.
Sample Input
2 3 2
1 2 -1
3 -1 0
-1 0
0 2
1 3
-2 -1
-3 -2
Sample Output
No
1 2
1
Hint
The test set contains large-size input. Iostream objects in C++ or Scanner in Java might lead to efficiency problems.
Source
POJ Monthly--2007.04.01, zhucheng

题目大意是,有一种新机器(PM3)被开发出来用于计算超大矩阵的乘法,但是存在一点小问题,PM3算出的结果矩阵可能存在一个元素是错的,并且至多一个元素是错的。请你检查并纠正PM3的计算结果。

搜索更多相关主题的帖子: 题目 讨论 
2007-05-22 12:14
crackerwang
Rank: 3Rank: 3
等 级:新手上路
威 望:8
帖 子:833
专家分:0
注 册:2007-2-14
收藏
得分:0 

抢沙发罗


2007-05-22 12:20
leeco
Rank: 4
等 级:贵宾
威 望:10
帖 子:1029
专家分:177
注 册:2007-5-10
收藏
得分:0 
居然没人做。
2007-05-22 19:38
thq2004423
Rank: 1
等 级:新手上路
帖 子:141
专家分:0
注 册:2005-12-15
收藏
得分:0 

编程很菜...
lz参加baidu的编程大赛吗?


2007-05-22 19:55
darklily
Rank: 1
等 级:新手上路
帖 子:42
专家分:0
注 册:2007-5-16
收藏
得分:0 

楼主.你把程序写出来看看,不会


2007-05-22 20:03
Eastsun
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:32
帖 子:802
专家分:0
注 册:2006-12-14
收藏
得分:0 
1:

#include<stdio.h>
char expr[101];
main(){
int index,flags;
long num,t;
char c;
while(scanf(\"%s\",expr)!=-1){
index =num =flags =t =0;
while(c=expr[index++]){
if(c!='+'&&c!='-') t =t*10 +c -'0';
else{
num += flags?-t:t;
t =0;
if(c=='-') flags =1;
}
}
num += flags?-t:t;
printf(\"%ld\n\",num);
}
}

My BlogClick Me
2007-05-22 20:16
darklily
Rank: 1
等 级:新手上路
帖 子:42
专家分:0
注 册:2007-5-16
收藏
得分:0 
看不懂.5555555555

2007-05-22 20:19
Eastsun
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:32
帖 子:802
专家分:0
注 册:2006-12-14
收藏
得分:0 

2:


#include<stdio.h>
#define MAX 1000

int A[MAX][MAX], B[MAX][MAX];
long C[MAX][MAX];
long AC[MAX],BR[MAX];
int N,P,M;
int r,c;
long v;
main(){
int ri,ci,ri1,ci1,flags;
long t;
while(scanf(\"%d%d%d\",&N,&P,&M)!=-1){
for(ri=0;ri<N;ri++)
for(ci=0;ci<P;ci++) scanf(\"%d\",&A[ri][ci]);
for(ri=0;ri<P;ri++)
for(ci=0;ci<M;ci++) scanf(\"%d\",&B[ri][ci]);
for(ri=0;ri<N;ri++)
for(ci=0;ci<M;ci++) scanf(\"%ld\",&C[ri][ci]);
flags =0;
for(ci=0;ci<P;ci++){
AC[ci] =0;
for(ri=0;ri<N;ri++) AC[ci] += A[ri][ci];
}
for(ri=0;ri<P;ri++){
BR[ri] =0;
for(ci=0;ci<M;ci++) BR[ri] += B[ri][ci];
}
for(ri=0;ri<N;ri++){
t =0;
for(ci1=0;ci1<P;ci1++) t +=A[ri][ci1]*BR[ci1];
for(ci1=0;ci1<M;ci1++) t -=C[ri][ci1];
if(t){
flags =1;
r =ri;
break;
}
}
if(!flags){
printf(\"Yes\n\");
continue;
}
for(ci=0;ci<M;ci++){
t =0;
for(ri1=0;ri1<P;ri1++) t +=AC[ri1]*B[ri1][ci];
for(ri1=0;ri1<N;ri1++) t -=C[ri1][ci];
if(t){
c =ci;
break;
}
}
v =0;
for(ci=0;ci<P;ci++) v +=A[r][ci]*B[ci][c];
printf(\"No\n%d %d\n%ld\",r+1,c+1,v);

}
}


My BlogClick Me
2007-05-22 21:24
nuciewth
Rank: 14Rank: 14Rank: 14Rank: 14
来 自:我爱龙龙
等 级:贵宾
威 望:104
帖 子:9786
专家分:208
注 册:2006-5-23
收藏
得分:0 
把一连串的+全部加起来.然后看前面的字符是+还是-就可以了.

倚天照海花无数,流水高山心自知。
2007-05-22 21:25
Eastsun
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:32
帖 子:802
专家分:0
注 册:2006-12-14
收藏
得分:0 
第二题居然写了两次才写对,ft~

My BlogClick Me
2007-05-22 21:25
快速回复:[讨论]第十六期编程题目
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.036254 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved