解いた問題

4/26/2012

SRM515 Div1 Easy

250

順番に試す。



class RotatedClock {
public:
  string getEarliest(int H, int M)
  {
    for (int i = 0; i < (int)360; i += 30) {
      int h = (360 + H - i) % 360;
      int m = (360 + M - i) % 360;
     
      int a = h % 30;

      if (m == a * 12) {
        char buff[100];
        sprintf(buff, "%02d:%02d", h / 30, m / 6);
        return string(buff);
      }
    }

    return "";
  }
};