2526.cpp (283B)
1 class DataStream { 2 const int value; 3 const int k; 4 int cnt = 0; 5 6 public: 7 DataStream(int value, int k) : value(value), k(k) {} 8 bool consec(int num) { 9 if (num == value) 10 cnt++; 11 else 12 cnt = 0; 13 14 return cnt >= k; 15 } 16 };