fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define el "\n"
  4. #define ll long long
  5. #define ull unsigned long long
  6. #define se second
  7. #define fi first
  8. #define be begin()
  9. #define en end()
  10. #define Faster cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
  11.  
  12. int kDigitsNumbers(int *a, int n, int k)
  13. {
  14. int ans = 0;
  15. for(int i = 0; i < n; i++)
  16. {
  17. int x = abs(a[i]);
  18. string s = to_string(x);
  19. if(s.size() == k) ans++;
  20. }
  21. return ans;
  22. }
  23. int main()
  24. {
  25. Faster;
  26. int n, k; cin >> n >> k;
  27. int *a = new int[n];
  28. for(int i = 0; i < n; i++) cin >> a[i];
  29. cout << kDigitsNumbers(a, n, k);
  30. return 0;
  31. }
  32.  
  33.  
Success #stdin #stdout 0.01s 5284KB
stdin
4 3
123 -999 0 2222
stdout
2