fork download
  1. #include <iostream>
  2.  
  3. int main()
  4. {
  5. unsigned long long num;
  6.  
  7. std::cin >> num;
  8.  
  9. unsigned int end = 0;
  10. unsigned int start = 0;
  11.  
  12. unsigned int tmpEnd = 0;
  13. unsigned int tmpStart = 0;
  14.  
  15. unsigned int length = 0;
  16. unsigned int tmpLength = 0;
  17.  
  18. unsigned int pos = 0;
  19. unsigned int cur = 9; // 0
  20.  
  21. while(num)
  22. {
  23. unsigned int c = num % 10;
  24.  
  25. if (c <= cur) // if (c >= cur)
  26. {
  27. cur = c;
  28. tmpEnd = pos;
  29. ++tmpLength;
  30. }
  31. else
  32. {
  33. if (tmpLength > length)
  34. {
  35. length = tmpLength;
  36. end = tmpEnd;
  37. start = tmpStart;
  38. }
  39.  
  40. tmpStart = pos;
  41. cur = 9; // 0
  42. tmpLength = 1;
  43. }
  44.  
  45. ++pos;
  46.  
  47. num = num/10;
  48. }
  49.  
  50. if (length < 2)
  51. {
  52. std::cout << "NO!!!" << std::endl;
  53. }
  54. else
  55. {
  56. std::cout << pos - end << ":" << pos - start << ":" << length << std::endl;
  57. }
  58.  
  59. return 0;
  60. }
Success #stdin #stdout 0s 3144KB
stdin
65431234123
stdout
5:8:4