Saturday, June 7, 2014

Topcoder High School SRM 6 Level one - 250 pt - Digital Display solution

Topcoder High School SRM 6 Level one - 250 pt - Digital Display statement: http://community.topcoder.com/stat?c=problem_statement&pm=6492&rd=10058

Topcoder High School SRM 6 Level one - 250 pt - Digital Display editorial: http://community.topcoder.com/tc?module=Static&d1=hs&d2=match_editorials&d3=hs_srm6

Topcoder High School SRM 6 Level one - 250 pt - Digital Display solution:

#include <iostream>
#include <cstdio>

using namespace std;

class DigitalDisplay {
    public: int waysToInterpret(string display) {
        int a[4], cnt=0;
        sscanf(display.c_str(), "%d:%d:%d", &a[0], &a[1], &a[2]);
        for(int i=0; i<3; i++) if(a[i%3]>=01 && a[i%3]<=12 && a[(i+1)%3]>=00 && a[(i+1)%3]<=59 && a[(i+2)%3]>=00 && a[(i+2)%3]<=59) cnt++;
        return cnt*2;
    }
};


No comments:

Post a Comment