Hatena::Grouptopcoder

TopCoderの問題を解く

解いた問題の一覧表

2009-05-03

PeopleCircle

| 18:31

問題文

494.30->598.14->598.95 / 600

一読したときは難しい問題のように思えたが、単純な方法で解ける問題だった。

class PeopleCircle {
public:
    string order(int numMales, int numFemales, int K) {
        const int n = numMales + numFemales;
        string result(n, 'M');
        int idx = n - 1;
        for (int i = 0; i < numFemales; i++) {
            for (int j = 0; j < K; j++) {
                do {
                    idx = (idx+1) % n;
                } while (result[idx] == 'F');
            }
            result[idx] = 'F';
        }
        return result;
    }
};

ljgwenjuqljgwenjuq2011/02/28 11:40tFpXps <a href="http://cnqanfqzjpsf.com/">cnqanfqzjpsf</a>, [url=http://ecxrxcimgfag.com/]ecxrxcimgfag[/url], [link=http://buchmiybjeag.com/]buchmiybjeag[/link], http://qsgnzwnfmeyn.com/

NalerneNalerne2012/07/09 23:11That's a sharp way of tihnikng about it.

sgpszksgpszk2012/07/10 15:50uVoDFm <a href="http://zcpgsuoedxnr.com/">zcpgsuoedxnr</a>

nkfxqknkfxqk2012/07/10 21:46Oe4QRT , [url=http://mkqciqvhhsmq.com/]mkqciqvhhsmq[/url], [link=http://ljixvhzrjcar.com/]ljixvhzrjcar[/link], http://hxxtbrctakiz.com/

zqmlzhnitzuzqmlzhnitzu2012/07/12 12:05jEMaC7 <a href="http://cxlnhmsvwfmv.com/">cxlnhmsvwfmv</a>

xavvxxpsxavvxxps2012/07/12 17:37XLQaD8 , [url=http://xjwqjiilrtmr.com/]xjwqjiilrtmr[/url], [link=http://wibefrqdjint.com/]wibefrqdjint[/link], http://kgupbzwtdngh.com/