April Fools Day Contest 2016 C. Without Text 信号与系统

C. Without Text

题目连接:

http://www.codeforces.com/contest/656/problem/C

Description

You can preview the image in better quality by the link: http://assets.codeforces.com/files/656/without-text.png

Input

The only line of the input is a string (between 1 and 50 characters long, inclusive). Each character will be an alphanumeric character or a full stop “.”.

Output

Output the required answer.

Sample Input

Codeforces

Sample Output

-87

Hint

题意

给你一个信号系统,然后问你输出是啥

题解:

还好我专业课是信号与系统,没事儿干就看这种图片……

模拟模拟就好了

代码

#include<bits/stdc++.h>
using namespace std;

string s;
int id(char c)
{
    if(c>='A'&&c<='Z')return c-'A'+1;
    if(c>='a'&&c<='z')return c-'a'+1;
}
int main()
{
    long long res = 0;
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        char a1 = '@';
        char a2 = '[';
        char a3 = '`';
        char a4 = '{';
        int flag1 = (a1<s[i])&(a2>s[i]);
        int flag2 = (a3<s[i])&(a4>s[i]);
        res = res + (flag1*id(s[i]))-(flag2*id(s[i]));
    }
    cout<<res<<endl;
}
    原文作者:qscqesze
    原文地址: https://www.cnblogs.com/qscqesze/p/5348072.html
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞