fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n,k,x,suma=0;
  6. cin>>n>>k;
  7. while(n){
  8. cin>>x;
  9. int s=0;
  10. while(x>9){
  11. s=s+x%10;
  12. x=x/10;}
  13. if(k==x)
  14. {
  15. suma=suma+s+x;
  16. }
  17. n--;
  18. }
  19. cout<<suma;
  20. return 0;
  21. }
Success #stdin #stdout 0s 5308KB
stdin
4 2
234 354 289 123
stdout
28