Hatena::Grouptopcoder

TopCoderの問題を解く

解いた問題の一覧表

2009-08-15

RPG

| 16:56

問題文

サイコロの出目の合計値として考えられる、最低値、最高値、平均値を計算する。

236.38/250

class RPG {
    public:
        vector <int> dieRolls(vector <string> dice) {
            vector <int> result(3, 0);
            double average = 0.0;
            for (int i = 0; i < dice.size(); i++) {
                int n, x;
                sscanf(dice[i].c_str(), "%dd%d", &n, &x);
                result[0] += n;
                result[1] += n * x;
                average += n*(x+1)/2.0l;
            }
            result[2] = static_cast<int>(average);
            return result;
        }
};

TrevonTrevon2011/07/22 14:31What a joy to find such clear thikinng. Thanks for posting!

jknzrlrnojknzrlrno2011/07/22 23:00AjjYSE <a href="http://ixlymfbzzugw.com/">ixlymfbzzugw</a>

yvzbbdyvzbbd2011/07/23 22:15ye8QTD , [url=http://uxgtugxylomn.com/]uxgtugxylomn[/url], [link=http://kqcpcalkwsod.com/]kqcpcalkwsod[/link], http://qqpqjszskcfr.com/

zjjbnlaeddzzjjbnlaeddz2011/07/24 22:34EkvlNg <a href="http://ziovfuvshgpt.com/">ziovfuvshgpt</a>

kredwoskredwos2011/07/26 01:32v3mrNH , [url=http://zmgqozacpuiq.com/]zmgqozacpuiq[/url], [link=http://vvwzqzdemmen.com/]vvwzqzdemmen[/link], http://hmhrbmsipkkf.com/

CamiloCamilo2012/11/16 17:32It's wondeurfl to have you on our side, haha!

amnquhsamnquhs2012/11/16 22:35OOQfVh <a href="http://wykjstupxxmy.com/">wykjstupxxmy</a>

etogorusetogorus2019/05/05 21:25http://mewkid.net/buy-amoxicillin/ - Amoxicillin 500mg Capsules <a href="http://mewkid.net/buy-amoxicillin/">Online Amoxicillin</a> wgo.cyyp.topcoder.g.hatena.ne.jp.sog.xx http://mewkid.net/buy-amoxicillin/