April Fools Day Contest 2016 F. Ace It!

F. Ace It!

题目连接:

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

Description

Input

The only line of the input is a string of 7 characters. The first character is letter A, followed by 6 digits. The input is guaranteed to be valid (for certain definition of “valid”).

Output

Output a single integer.

Sample Input

A221033

Sample Output

21

Hint

题意

给你一个字符串,然后输出答案

题解:

仔细观察,大胆猜测,就是数位数字之和,A是1,1是10

然后不要oeis hhh

代码

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

string s;
int main()
{
    cin>>s;
    int res = 0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]>='2'&&s[i]<='9')
            res+=(int)(s[i]-'0');
        else if(s[i]=='1')res+=10;
    }
    cout<<res+1<<endl;
}
    原文作者:qscqesze
    原文地址: https://www.cnblogs.com/qscqesze/p/5348131.html
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞