题目来源:http://community.topcoder.com/stat?c=problem_statement&pm=3003&rd=5858

比较简单。

代码如下:

#include <iostream>
#include <vector>
#include <cmath>
#include <string> using namespace std; #define Rate(win, i) ( (double)(win) / (double)(i) * 100)
#define PRECISE 0.000001 class WinningRecord
{
public:
vector <int> getBestAndWorst(string games);
}; vector <int> WinningRecord::getBestAndWorst(string games)
{
int i;
int best, worst, win;
double bestRate, worstRate, rate;
int length;
vector <int> ans; best = worst = win = 0;
length = games.size();
bestRate = 0;
worstRate = 100; for (i = 0; i < 2; i++) {
if ('W' == games[i]) {
++win;
}
} for (i = 2; i < length; i++) {
if ('W' == games[i]) {
++win;
} rate = Rate(win, i+1);
if ( rate - bestRate > PRECISE || abs(bestRate - rate) < PRECISE ) {
bestRate = rate;
best = i + 1;
} if ( worstRate - rate > PRECISE || abs(worstRate - rate) < PRECISE ) {
worstRate = rate;
worst = i + 1;
}
} ans.push_back(best);
ans.push_back(worst);
return ans;
}

SRM 212 Div II Level Two: WinningRecord,Brute Force的更多相关文章

  1. SRM 582 Div II Level Three: ColorTheCells, Brute Force 算法

    题目来源:http://community.topcoder.com/stat?c=problem_statement&pm=12581 Burte Force 算法,求解了所有了情况,注意  ...

  2. SRM 223 Div II Level Two: BlackAndRed,O(N)复杂度

    题目来源:http://community.topcoder.com/stat?c=problem_statement&pm=3457&rd=5869 解答分析:http://comm ...

  3. SRM 207 Div II Level Two: RegularSeason,字符串操作(sstream),多关键字排序(操作符重载)

    题目来源:http://community.topcoder.com/stat?c=problem_statement&pm=2866&rd=5853 主要是要对字符串的操作要熟悉,熟 ...

  4. SRM 219 Div II Level One: WaiterTipping,小心约分

    题目来源:http://community.topcoder.com/stat?c=problem_statement&pm=12609&rd=15503 这题目看上去so easy, ...

  5. SRM 212 Div II Level One: YahtzeeScore

    题目来源:http://community.topcoder.com/stat?c=problem_statement&pm=1692&rd=5858 比较简单. 代码如下: #inc ...

  6. SRM 583 Div II Level Three:GameOnABoard,Dijkstra最短路径算法

    题目来源:http://community.topcoder.com/stat?c=problem_statement&pm=12556 用Dijkstra实现,之前用Floyd算法写了一个, ...

  7. SRM 582 Div II Level One: SemiPerfectSquare

    题目来源:http://community.topcoder.com/stat?c=problem_statement&pm=12580 比较简单,代码如下: #include <ios ...

  8. SRM 577 Div II Level Two: EllysRoomAssignmentsDiv2

    题目来源: http://community.topcoder.com/tc?module=ProblemDetail&rd=15497&pm=12521 这个问题要注意的就是只需要直 ...

  9. SRM 582 Div II Level Two SpaceWarDiv2

    题目来源:http://community.topcoder.com/stat?c=problem_statement&pm=12556 #include <iostream> # ...

随机推荐

  1. c++ primer 4 数组和指针

    类比的思想学习数组和指针,c++提供类似于vector和迭代器的低级复合类型——数组和指针.与vector相似,数组可以保存某一种类型的一组对象:而他们的区别在于,数组的长度固定,数组一经创建就不允许 ...

  2. [实战]MVC5+EF6+MySql企业网盘实战(20)——Bootstrap Paginator

    写在前面 考虑到数据量的问题,特引入bootstrap的分页插件.插件下载地址:https://github.com/lyonlai/bootstrap-paginator 系列文章 [EF]vs15 ...

  3. 【LOJ】#2014. 「SCOI2016」萌萌哒

    题解 这个题好妙啊 首先我们发现,如果我们可以暴力,就是把相同的元素拿并查集合起来,最后统计集合个数\(cnt\) 答案是\(9\*10^{cnt - 1}\) 然而我们做不到= = 我们可以用倍增的 ...

  4. 【LOJ】#2280. 「FJOI2017」矩阵填数

    题解 我们发现没有限制的小方格可以随便填 然后考虑有限制的,我们把它切割成一个个小块(枚举相邻的横纵坐标),然后记录一下这个小块的最大值限制(也就是所有覆盖它的矩形最小的最大值) 记录一下每个小块的大 ...

  5. angular4 动态Form中获取表单字段并在页面中使用的方法

    主要有两种方式 第一种 使用get属性 页面中使用如下: 第二种 使用普通方法事件  页面中使用如下 *转载请附出处

  6. django配置templates、static、media和连接mysql数据库

    1.模板文件 # =======templates配置======= if os.path.exists(os.path.join(BASE_DIR, 'templates')) is False: ...

  7. Codeforces 521 E cycling city

    cf的一道题,非常有意思,题目是问图中是否存在两个点,使得这两个点之间有三条路径,而且三条路径没有公共点. 其实就是判断一下是否为仙人掌就行了,如果不是仙人掌的话肯定就存在,题目难在输出路径上,改了半 ...

  8. luoguP3317 [SDOI2014]重建 变元矩阵树定理 + 概率

    首先,我们需要求的是 $$\sum\limits_{Tree} \prod\limits_{E \in Tree} E(u, v) \prod\limits_{E \notin Tree} (1 - ...

  9. [CSAcademy]Squared Ends

    [CSAcademy]Squared Ends 题目大意: 给你一个长度为\(n(n\le10^4)\)的数列\(\{A_i\}(A_i\le10^6)\).定义区间\(A_{[l,r]}\)的代价为 ...

  10. JSP -- include指令与include动作的区别

    JSP -- include指令与include动作的区别 (1)格式的区别: include指令:<%@include file = "文件名"%> include动 ...