SRM 212 Div II Level Two: WinningRecord,Brute Force
题目来源: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的更多相关文章
- SRM 582 Div II Level Three: ColorTheCells, Brute Force 算法
题目来源:http://community.topcoder.com/stat?c=problem_statement&pm=12581 Burte Force 算法,求解了所有了情况,注意 ...
- SRM 223 Div II Level Two: BlackAndRed,O(N)复杂度
题目来源:http://community.topcoder.com/stat?c=problem_statement&pm=3457&rd=5869 解答分析:http://comm ...
- SRM 207 Div II Level Two: RegularSeason,字符串操作(sstream),多关键字排序(操作符重载)
题目来源:http://community.topcoder.com/stat?c=problem_statement&pm=2866&rd=5853 主要是要对字符串的操作要熟悉,熟 ...
- SRM 219 Div II Level One: WaiterTipping,小心约分
题目来源:http://community.topcoder.com/stat?c=problem_statement&pm=12609&rd=15503 这题目看上去so easy, ...
- SRM 212 Div II Level One: YahtzeeScore
题目来源:http://community.topcoder.com/stat?c=problem_statement&pm=1692&rd=5858 比较简单. 代码如下: #inc ...
- SRM 583 Div II Level Three:GameOnABoard,Dijkstra最短路径算法
题目来源:http://community.topcoder.com/stat?c=problem_statement&pm=12556 用Dijkstra实现,之前用Floyd算法写了一个, ...
- SRM 582 Div II Level One: SemiPerfectSquare
题目来源:http://community.topcoder.com/stat?c=problem_statement&pm=12580 比较简单,代码如下: #include <ios ...
- SRM 577 Div II Level Two: EllysRoomAssignmentsDiv2
题目来源: http://community.topcoder.com/tc?module=ProblemDetail&rd=15497&pm=12521 这个问题要注意的就是只需要直 ...
- SRM 582 Div II Level Two SpaceWarDiv2
题目来源:http://community.topcoder.com/stat?c=problem_statement&pm=12556 #include <iostream> # ...
随机推荐
- 猜数字游戏的提示(UVa340)
题目具体描述见:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_prob ...
- ASP.NET Zero--4.不使用谷歌字体,提升加载速度
jtable控件样式中会使用到谷歌字体,每次访问都特别慢 1.打开jtable.css文件 [..\MyCompanyName.AbpZeroTemplate.Web\libs\jquery-jtab ...
- ScrureCRT访问CentOS时出现乱码的解决办法
1. ScrureCRT访问CentOS时,出现乱码. 登陆后,输入日历命令:cal 输出日历带有乱码的结果: 2. 查看当前系统的语言. 输入命令:echo $LANG 输出:zh_CN.UTF ...
- GeneXus项目启动
使用GeneXus产品开发项目时,在开始,有一些属性我会经常改一下.我现在使用的GeneXus版本是GeneXus U3,由于在做手机应用的开发,所以一般使用最新的版本,老外那边差不多两个月会有一个u ...
- Am335x u-boot 启动过程中的系统频率配置
Am335x的时钟结构分为:ADPLLS和ADPLLLJ 1.ADPLLS用来配置Core_CLK,Dispaly_clk,ARM系统CLK(mpu_clk),DDR PLLs_clk 2.ADPLL ...
- 2017/11/7 Leetcode 日记
2017/11/7 Leetcode 日记 669. Trim a Binary Search Tree Given a binary search tree and the lowest and h ...
- 看雪论坛 破解exe 看雪CTF2017第一题分析-『CrackMe』-看雪安全论坛
韩梦飞沙 韩亚飞 313134555@qq.com yue31313 han_meng_fei_sha 逆向 黑客 破解 学习 论坛 『CrackMe』 http://bbs.pediy.co ...
- codevs 1102 采药 2005年NOIP全国联赛普及组
1102 采药 2005年NOIP全国联赛普及组 时间限制: 1 s 空间限制: 128000 KB gold 题目描述 Description 辰辰是个天资聪颖的孩子,他的梦想是成为世界上最 ...
- [JZYZOJ 1288][洛谷 1005] NOIP2007 矩阵取数 dp 高精度
https://www.luogu.org/problem/show?pid=1005 dp好想,高精度练手题,有点不舒服的是前后取数位置的计算,代码量太少才会写题这么慢,noip之前虽然重点放在 ...
- 【最小表示法】BZOJ2882-工艺
[题目大意] 求一个循环数列的最小表示法. [思路] 最小表示法模板题.之前用SAM做的,MLE了hhhhh戳☆ #include<iostream> #include<cstdio ...