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;
                }
            };

  • 相关阅读:
    交互式shell和非交互式shell、登录shell和非登录shell的区别
    cocos2d-x入门笔记(1)
    《你的知识需要管理》读后感悟以及笔记
    Qt入门之信号与槽机制
    《程序员的思维修炼》读书笔记以及感悟
    Py邮件
    2018-2019 20165226 Exp9 Web安全基础
    2018-2019 20165226 Exp 8 Web基础
    2018-2019 20165226 Exp7 网络欺诈防范
    2018-2019 20165226 Exp6 信息搜集与漏洞扫描
  • 原文地址:https://www.cnblogs.com/exclm/p/1361841.html
Copyright © 2011-2022 走看看