首页 > ACM题库 > HDU-杭电 > hdu 2893 cube[解题报告]hoj
2014
02-17

hdu 2893 cube[解题报告]hoj

cube

问题描述 :

小白一直想写一份模板,作用是计算N个长方体的体积并,你能帮帮他么?

输入:

首先输入一个N,代表接下去将要输入N个长方体。
接着输入N个长方体,每行输入3个数字,x , y , z 分别代表长方体的长宽高(我们可以简单的看做长方体的两个对角为(0,0,0)和(x,y,z))。0<n, x ,y ,z < 10000;

输出:

首先输入一个N,代表接下去将要输入N个长方体。
接着输入N个长方体,每行输入3个数字,x , y , z 分别代表长方体的长宽高(我们可以简单的看做长方体的两个对角为(0,0,0)和(x,y,z))。0<n, x ,y ,z < 10000;

样例输入:

4
1 1 1
2 2 2
2 2 3
3 2 2

样例输出:

16


YY, and YY
again
Time limit:
10sec.
Submitted:
278
Memory limit:
64M
Accepted:
182
Source: 2009
ACM/ICPC Asia Regional Harbin Site Onsite
Description
If we define each of the upper case letters a number, that is, 1
for A, 2 for B, 3 for C, … 25 for Y, 26 for Z, we can calculate a
mark for any word or sentence.
We believe that 100 points is the full mark, so for those word with
a mark larger than 100, we should just ignore that, with a label
“INVALID”. Then lets see interesting results:
What is the most important for your success?
HARD WORK? H+A+R+D+W+O+R+K=8+1+18+4+23+15+18+11=98
KNOWLEDGE? K+N+O+W+L+E+D+G+E=11+14+15+23+12+5+4+7+5=96
MONEY?(72)
LUCK?(47)
ATTITUDE! A+T+T+I+T+U+D+E=1+20+20+9+20+21+4+5=100
So just be with good attitude and you will be on your way to
success.
Input
For each case of the input, it contains a single line. For each
line, some characters will appear with maybe some of them being
upper case letters. All characters are printable. Each line will
have at most 127 characters.
Output
For each case, you should only pay attention to upper case letters
and calculate the total points. If it is over 100, “INVALID” should
be returned. Or you should print the exact point of that.
Sample Input
DELICIOUS FOOD
YY, and YY again!
did i lose anything?
Sample Output
INVALID
100
0
代碼中含有全角空格,請勿直接copy,否則會compilation error 
#include <iostream>
#include <cstring>
using namespace std;
int main(int argc, char** argv) {
    const int size = 128;
    char list[size];
    int i, sum;
    while (cin.getline(list, size)) {
        sum = 0;
        for (i = 0; i < strlen(list); i++) {
            if (list[i] > 64 && list[i] < 97) 
                sum += static_cast<int> (list[i]) - 64;
        }
        if (sum > 100)cout << ”INVALID” << endl;
        else cout << sum << endl;
    }
    return 0;
}
解题参考:http://blog.sina.com.cn/s/blog_6d186d330100pou8.html


  1. L(X [0 .. M-1],Y [0 .. N-1])= 1 + L(X [0 .. M-2],Y [0 .. N-1])这个地方也也有笔误
    应改为L(X [0 .. M-1],Y [0 .. N-1])= 1 + L(X [0 .. M-2],Y [0 .. N-2])

  2. 算法是程序的灵魂,算法分简单和复杂,如果不搞大数据类,程序员了解一下简单点的算法也是可以的,但是会算法的一定要会编程才行,程序员不一定要会算法,利于自己项目需要的可以简单了解。