fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int TEN = 10;
  5.  
  6. int main() {
  7. int n, x, currentDigit;
  8. cin >> n >> x;
  9. while (cin >> currentDigit) {
  10. if (currentDigit == 1) {
  11. ++n;
  12. } else {
  13. n *= TEN;
  14. }
  15. }
  16. cout << n;
  17. return 0;
  18. }
Success #stdin #stdout 0.01s 5276KB
stdin
9 5
1 1 1 1 1 -> 14
stdout
14