fork(8) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. long long num, now, nex, ans = 0;
  5. string s;
  6. bool naik;
  7. bool turun;
  8.  
  9. int main () {
  10. for(long long bil=0; bil<10000000000; bil++) {
  11. naik = true;
  12. turun = true;
  13. num = bil;
  14.  
  15. nex = -1;
  16. while (num > 0) {
  17. now = num%10;
  18. if (nex != -1) {
  19. if (now > nex) naik = false;
  20. if (now < nex) turun = false;
  21. }
  22. nex = now;
  23. num = num / 10;
  24. }
  25.  
  26. if (naik || turun) {
  27. ans++;
  28. }
  29. }
  30. cout << ans << endl;
  31. return 0;
  32. }
Time limit exceeded #stdin #stdout 5s 4388KB
stdin
Standard input is empty
stdout
Standard output is empty