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;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值