fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. long int n, k, count, maxamountOf0, 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. maxamountOf0 = count >= min? count:min;
  24.  
  25. if( maxamountOf0 == count ){
  26. if( n = min ){
  27. answer = n;
  28. }
  29. else{
  30. answer = answer > n? n:answer;
  31. }
  32. }
  33. else if( maxamountOf0 > min ) answer = n;
  34. min = maxamountOf0;
  35. }
  36. //cout << answer << ' ';
  37. a = answer;
  38. if( a < 10000000000 ) withoutO = 0;
  39. }
  40. //cout << maxamount << ' ';
  41. if(withoutO != 0){
  42. cout<< withoutO;
  43. }
  44. else{
  45. cout << a << endl;
  46. }
  47. }
Success #stdin #stdout 0.01s 5404KB
stdin
4
71200
10
100
3000
stdout
2