fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. long int n, k, count, maxamount, min = 0, a, minmin, p;
  6. long int num = 100000000000, answer = 100000000000, withoutO = 10000000000;
  7. cin>> p;
  8.  
  9. while(cin >> n){
  10. int k = n;
  11. count = 0;
  12. while(k>0){
  13. if(k%10==0){
  14. count++;
  15. k/=10;
  16. }
  17. else{
  18. withoutO = n < withoutO? n:withoutO;
  19. k = -1;
  20. }
  21. }
  22. if( count > 0 ){
  23. maxamount = count >= min? count : min;
  24. min = maxamount;
  25. }
  26. if( maxamount == count ){
  27. if( n < maxamount){
  28. answer = n;
  29. }
  30. else{
  31. answer = answer > n? n:answer;
  32. }
  33. }
  34. //cout << maxamount << ' ';
  35. a = answer;
  36. if( a < 10000000000 ) withoutO = 0;
  37. }
  38.  
  39. if(withoutO != 0){
  40. cout<< withoutO;
  41. }
  42. else{
  43. cout << a << endl;
  44. }
  45.  
  46. }
Success #stdin #stdout 0.01s 5464KB
stdin
2
23 4
stdout
4