fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. bool valid(long long x)
  5. {
  6. while (x)
  7. {
  8. int d = x % 10;
  9. if (d == 4)
  10. return false;
  11. x /= 10;
  12. }
  13. return true;
  14. }
  15.  
  16. int main()
  17. {
  18. int tests;
  19. cin >> tests;
  20. for (int t = 1; t <= tests; t++)
  21. {
  22. long long N, A = 1, B;
  23. cin >> N;
  24. B = N - A;
  25. while (true)
  26. {
  27. if (valid(A) && valid(B))
  28. {
  29. cout << "Case #" << t << ": " << A << " " << B << endl;
  30. break;
  31. }
  32. A++, B--;
  33. }
  34. }
  35. }
  36.  
Time limit exceeded #stdin #stdout 5s 15240KB
stdin
Standard input is empty
stdout
Standard output is empty