zoukankan      html  css  js  c++  java
  • topcode SRM 577 DIV2 EllysRoomAssignmentsDiv2

    很郁闷的一题,一定要认真读题目,特别注意这句话   Concatenate its elements to obtain one long string,,,一定要理解这句话

     1 #include <iostream>
     2 #include <string>
     3 #include <vector>
     4 #include <algorithm>
     5 #include <sstream>
     6 #include <numeric>
     7 using namespace std;
     8 
     9 class EllysRoomAssignmentsDiv2{
    10 public:
    11     double getProbability(vector <string> ratings){
    12         string split="";
    13         string all = accumulate(ratings.begin(),ratings.end(),split);
    14         stringstream sst(all);
    15         vector<int> score;
    16         int tmp;
    17         while(sst >> tmp) score.push_back(tmp);
    18         int score_elly = score[0];
    19         sort(score.begin(),score.end(),greater<int>());
    20         int cnt_elly = 0;
    21         for(int i = 0 ; i < score.size(); i ++  ){
    22             if( score[i] == score_elly) {
    23                 cnt_elly = i;break;
    24             }
    25         }
    26         int R = score.size()%20 ? score.size()/20+1 : score.size()/20;
    27         if(R <= 1 || cnt_elly == 0 ) return 1.0;
    28         else if( cnt_elly < R ) return 0.0;
    29         else return 1.0/R;
    30 
    31     }
    32 };

      

  • 相关阅读:
    014_Python3 循环语句
    013_Python3 条件控制
    012_Python3 斐波纳契数列 + end 关键字
    011_Python3 集合
    010_Python3 字典
    009_Python3 元组
    008_Python3 列表
    006_Python3 数字(Number)
    005_Python3 运算符
    bzoj3160
  • 原文地址:https://www.cnblogs.com/xiongqiangcs/p/3050046.html
Copyright © 2011-2022 走看看