fork(2) download
  1. # include <iostream>
  2. # include <cstdio>
  3. # include <queue>
  4. using namespace std;
  5. unsigned long long Input;
  6. int main(int argc, char const *argv[])
  7. {
  8. //freopen ("370_ONEZERO_input.txt", "r", stdin);
  9. //freopen ("370_ONEZERO_output.txt", "w", stdout);
  10. int N;
  11. cin >> N;
  12. //scanf ("%d", &N);
  13. unsigned long long current = 0;
  14. queue <unsigned long long> Queue;
  15. for (int i = 0; i < N; i++)
  16. {
  17.  
  18. cin >> Input;
  19. //scanf ("%d", &Input);
  20. //if (Input == 1) {printf ("1\n"); continue;} //cout << "1" << endl; continue;}
  21. //if (Input == 1) {cout << "1" << endl; continue;}
  22. Queue.push (11ULL); Queue.push (18ULL);
  23. while (!Queue.empty())
  24. {
  25. current = Queue.front();
  26. Queue.pop();
  27. if (current % Input)
  28. {
  29. Queue.push (current * 10ULL + 1ULL);
  30. Queue.push ((current * 10ULL) + 8ULL);
  31. }
  32. else
  33. {
  34. cout << current << endl;
  35. //printf ("%d\n", current);
  36. while (!Queue.empty()) Queue.pop();
  37. }
  38. }
  39. }
  40. return 0;
  41. }
Success #stdin #stdout 0.02s 2820KB
stdin
3
17
11011
17
stdout
11101
11011
11101