zoukankan      html  css  js  c++  java
  • 又去Topcoder菜了一回

        好久没登陆 Topcoder Arena 了,上一次登陆是五月份,当时随ACM 协会去南师大比赛了一次,当时菜极了,什么都不会,连 iterator、vector都不会,看着简单的杂题和01背包问题,只能眼巴巴提交不成功0分归来……当时连挑刺都不会呀……

        今没事干,安装了 Arena ,做了一题练习题2001-R1-prob01-250,250分的,却值得了 76.3……为什么呢?


            #include <iostream>
            #include <string>

            using namespace std;

            class HowEasy{
            public:
                int pointVal(string problemStatement)
                {
                    int len, chars;
                    int lengthsSum = 0, wordsNum = 0;
                    int i = 0, level;
                   
                    problemStatement += ' ';
                    while(i < problemStatement.size())
                    {
                        len = chars = 0;
                        while(i < problemStatement.size())
                        {
                            if (problemStatement[i] == ' ')
                            {
                                if (chars < 2)
                                {
                                    lengthsSum += len;
                                    break;
                                }
                            }
                            if ((problemStatement[i] >= 'a' && problemStatement[i] <= 'z') ||
                                (problemStatement[i] >= 'A' && problemStatement[i] <= 'Z'))
                            {
                                len++;
                            }
                            else
                            {
                                chars++;
                            }
                            i++;
                        }
                        i++;
                        wordsNum++;
                    }
                    switch(lengthsSum / wordsNum)
                    {
                    case 0:
                    case 1:
                    case 2: level = 1; break;
                    case 3:
                    case 4:
                    case 5: level = 2; break;
                    default: level = 4; break;
                    }
                    return level * 250;
                }
            };

  • 相关阅读:
    NSArray & NSDictionary
    copy&mutableCopy 浅拷贝(shallow copy)深拷贝 (deep copy)
    03-图形上下文栈, 图形的平移 旋转 缩放
    02- 画文字和图片-------------之前写的那个微博项目,可以试试用画图片的方式来处理,这样应该比UILabel 代码少点,一会试试
    Quartz 官网翻译(转载)
    01 画简单线的方法
    @property 修饰符
    SEL 类型
    Java 常用快捷键
    Java判断是否为数字
  • 原文地址:https://www.cnblogs.com/exclm/p/1361841.html
Copyright © 2011-2022 走看看