字符->UVALive 4773 YY and YY Again
2013-10-12 18:24
513 查看
YY and YY AgainTime Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %lluSubmit Status Practice UVALive4773DescriptionIf 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=98KNOWLEDGE? K+N+O+W+L+E+D+G+E=11+14+15+23+12+5+4+7+5=96MONEY?(72)LUCK?(47)ATTITUDE! A+T+T+I+T+U+D+E=1+20+20+9+20+21+4+5=100So just be with good attitude and you will be on your way to success.InputFor 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 127characters.OutputFor 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;}[/code]
相关文章推荐
- UVALive 7410 && POJ 5583 Kingdom of Black and White (枚举)
- ACM->uvalive->Sentry Robots(二分图匹配的最小点覆盖)
- DP->UVALive 4764
- UVALive 7146 muliset<> 容器用法 防御塔
- 【UVALive】3029.City Game<C++>
- UVALive - 5088 Alice and Bob's Trip
- Rails requires RubyGems >= 1.3.1 (you have 1.2.0). Please `gem update --system` and try again.
- [UVALive5760] Alice and Bob && 博弈
- hdoj 1068 Girls and Boys<二分图>
- Pointer-to-Member Operators: .* and ->*
-  |"|&|<|>等html字符转义
- between..and-->open bound or close bound?
- Bitmap.createBitmap java.lang.IllegalArgumentException: width and height must be > 0 问题解决
- 【转义字符】HTML 字符实体< >: &等
- [Java] Convert Between the Two, String[] and ArrayList<String>
- UVALive 6665 Dragon&#226;s Cruller --BFS,类八数码问题
- &nbsp|&quot|&amp|&lt|&gt等html字符转义
- Linux界面切换:图形界面<——>字符界面
- ACM->uva748
- C语言 给字符数组赋值的方法<转>