fork(2) 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. srand(time(NULL));
  19. int tests;
  20. cin >> tests;
  21. for (int t = 1; t <= tests; t++)
  22. {
  23. long long N, A, B;
  24. cin >> N;
  25. long long _min = 1, _max = N - 1;
  26. while (true)
  27. {
  28. A = (_min + (rand() % (long long)(_max - _min + 1)));
  29. B = N - A;
  30. if (valid(A) && valid(B))
  31. {
  32. cout << "Case #" << t << ": " << A << " " << B << endl;
  33. break;
  34. }
  35. }
  36. }
  37. }
  38.  
Time limit exceeded #stdin #stdout 5s 15240KB
stdin
Standard input is empty
stdout
Standard output is empty