您的位置:首页 > 其它

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

2016-04-02 19:22 330 查看

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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: