字符->UVALive 4773 YY and YY Again

YY and YY Again
Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu

Description

Download as PDF

If we define each of the upper case letters a number, that is, 1 for A, 2 for B, 3 for C, ... 25 for Y, 26 for Z, we can calculate a mark for any word or sentence.

We believe that 100 points is the full mark, so for those word with a mark larger than 100, we should just ignore that, with a label ``INVALID". Then let's see interesting results:

What is the most important for your success?

  • HARD WORK? H+A+R+D+W+O+R+K=8+1+18+4+23+15+18+11=98
  • KNOWLEDGE? K+N+O+W+L+E+D+G+E=11+14+15+23+12+5+4+7+5=96
  • MONEY?(72)
  • LUCK?(47)
  • ATTITUDE! A+T+T+I+T+U+D+E=1+20+20+9+20+21+4+5=100

So just be with good attitude and you will be on your way to success.

Input

For each case of the input, it contains a single line. For each line, some characters will appear with maybe some of them being upper case letters. All characters are printable. Each line will have at most 127 characters.

Output

For each case, you should only pay attention to upper case letters and calculate the total points. If it is over 100, ``INVALID" should be returned. Or you should print the exact point of that.

Sample Input

DELICIOUS FOOD 
YY, and YY again!
did i lose anything?

Sample Output

INVALID 
100 
0
 
   
 
   
#include <stdio.h>
#include <string.h>

char str1[200], str2[200];

int main()
{
    int ans;
    while(scanf("%s", str1) != EOF)
    {
        gets(str2);
        int len1 = strlen(str1), len2 = strlen(str2);
        ans = 0;
        for(int i = 0; i < len1; i++)
        {
            if(str1[i] >= 'A' && str1[i] <= 'Z')
            {
                ans += str1[i] - 'A' + 1;
            }
        }
        for(int i = 0; i < len2; i++)
        {
            if(str2[i] >= 'A' && str2[i] <= 'Z')
            {
                ans += str2[i] - 'A' + 1;
            }
        }
        if(ans > 100)
        {
            printf("INVALID\n");
        }
        else
        {
            printf("%d\n", ans);
        }
    }
    return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值