杭电ACM课件(lecture_02)简单数学题.ppt

  1. 1、本文档共75页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
杭电ACM课件(lecture_02)简单数学题

ACM程序设计 第二讲 老少皆宜之数学题 ACM数学题特点分析: 题意容易理解 算法相对简单(有些很难的!!) 编程比较容易 ACM/ICPC入门练习的好选择 下面,分类介绍: 从首届“舜宇”杯说起 比赛背景 由于前一年的邀请赛很多学校没有做出一道题,所以,这次的比赛特意准备了几道简单的题目,目的就是让大多数的学校都能拿个气球回去,也好有个交待,于是有… 第一类 1004: Let the Balloon Rise Problem Description Contest time again! How excited it is to see balloons floating around. But to tell you a secret, the judges favorite time is guessing the most popular problem. When the contest is over, they will count the balloons of each color and find the result. This year, they decide to leave this lovely job to you. Input Input contains multiple test cases. Each test case starts with a number N (0 N = 1000) -- the total number of balloons distributed. The next N lines contain one color each. The color of a balloon is a string of up to 15 lower-case letters. A test case with N = 0 terminates the input and this test case is not to be processed. ? Output For each case, print the color of balloon for the most popular problem on a single line. It is guaranteed that there is a unique solution for each test case. Sample Input 5 green red blue red red 3 pink orange pink 0 ? 题目评述: 1. 一个让你看到后兴奋的题目… 1004题目分析: 该题算法思想比较简单,就是对输入的字符串进行比较和统计。值得注意的一点是: 如果用C语言来写,要注意可能会把第一个数字后的“回车符”误认为是第一个串。 思路分析 设置两个数组: 一个数组color[],每个元素存储一个不同颜色 一个数组count[],每个元素count[i]存储颜色color[i]的出现次数 思路分析 (1)对i从1到n做 读入一个颜色str 在color数组中查找,若找不到,在表尾添加一个颜色,个数为1;若找到,对应颜色数加1 (2)遍历count数组,找到最大值count[i],则对应color[i]即所求颜色 1008: Elevator Problem Description The highest building in our city has only one elevator. A request list is made up with N positive numbers. The numbers denote at which floors the elevator will stop, in specified order. It costs 6 seconds to move the elevator up one floor, and 4 seconds to move down one floor. The elevator will stay for 5 seconds at each stop. For a given request list, you are to compute the total time spent to fulfill the requests on the list. The elevator is on the 0th floor at the beginning and does not have to return to the ground floor whe

文档评论(0)

shuwkb + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档