您的位置:首页 > 其它

HDU2734(简单题)

2014-12-09 09:16 295 查看
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2734

解题思路:

用isupper判断是否为大写字母,如果是,那对应相乘再相加,否则略过。

完整代码:

#include <functional>
#include <algorithm>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <cstring>
#include <climits>
#include <cassert>
#include <complex>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;

#pragma comment(linker, "/STACK:102400000,102400000")

typedef long long LL;
typedef double DB;
typedef unsigned uint;
typedef unsigned long long uLL;

/** Constant List .. **/ //{

const int MOD = int(1e9)+7;
const int INF = 0x3f3f3f3f;
const LL INFF = 0x3f3f3f3f3f3f3f3fLL;
const DB EPS = 1e-9;
const DB OO = 1e20;
const DB PI = acos(-1.0); //M_PI;

string s;

int main()
{
    #ifdef DoubleQ
    freopen("in.txt","r",stdin);
    #endif
    while(getline(cin , s))
    {
        if(s == "#")
            break;
        int len = s.length();
        LL sum = 0;
        for(int i = 0 ; i < len ; i ++)
        {
            if(isupper(s[i]))
                sum += (i + 1) * (s[i] - 'A' + 1);
        }
        cout << sum << endl;
        s = "";
    }
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: