Monday, June 9, 2014

Topcoder High School SRM 9 205 pt - Level one - Exciting Game solution

Topcoder High School SRM 9 205 pt - Level one - Exciting Game statement: http://community.topcoder.com/stat?c=problem_statement&pm=6633&rd=10061

Topcoder High School SRM 9 205 pt - Level one - Exciting Game editorial: http://community.topcoder.com/tc?module=Static&d1=hs&d2=match_editorials&d3=hs_srm9

Topcoder High School SRM 9 205 pt - Level one - Exciting Game solution:

#include <iostream>
using namespace std;

class ExcitingGame {
    public: int howMany(int n, int t, int w) {
        int a[1005]={0}, tmp=1, cnt=0, flag=0;
        while(flag==0) for(int i=0; i<n; i++) {
            a[i]=tmp;
            if(w==i && a[i]%3==0) cnt++;            
            if(tmp==t) {flag=1; break;}
            tmp++;
        }
        return cnt;
    }
};

No comments:

Post a Comment