fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. long long int n, min = 0, max = 1000000001, answer = 0, max_amount_of_0 = 0, without0;
  6. cin >> n;
  7. for(int i = 0; i < n; i++){
  8. long long int num, alsonum, count = 0, number;
  9. cin >> num;
  10. alsonum = num;
  11. while(alsonum > 0){
  12. if(alsonum % 10 == 0){
  13. count++;
  14. alsonum /= 10;
  15. }
  16. else{
  17. without0 = alsonum < max ? alsonum:without0;
  18. alsonum = -1; //останока while
  19. max = without0;
  20. //cout << without0 << ' ';
  21. }
  22. }
  23. //cout << without0 << ' ';
  24. if(count!=0){
  25. if(count > max_amount_of_0){
  26. answer = num;
  27. number = num;
  28. max_amount_of_0 = count;
  29. }
  30. else if(count == max_amount_of_0){
  31. //cout << num << ' ';
  32. answer = answer < num? answer:num;
  33. }
  34. //cout << max_amount_of_0 << ' ';
  35. //cout << min << ' ';
  36. //cout << num << ' ';
  37. }
  38. //cout << num << ' ';
  39. //cout << answer << ' ';
  40. }
  41. if(answer==0) cout << without0;
  42. else cout << answer;
  43. }
Success #stdin #stdout 0.01s 5516KB
stdin
5
10 20000 10 140000 1052500001
stdout
20000