Advertisement
a53

egale

a53
Jan 23rd, 2017
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. #include <fstream>
  2. #include <cassert>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. ifstream fin("egale.in");
  8. ofstream fout("egale.out");
  9.  
  10. int op;
  11. fin >> op;
  12. assert(op == 1 || op == 2);
  13.  
  14. if (op == 1) {
  15. long long a, b;
  16. fin >> a >> b;
  17.  
  18. assert(a <= b);
  19. //assert(a <= 100000000000000000LL && b <= 100000000000000000LL && a > 1000000000 && b > 1000000000);
  20.  
  21. long long curr = 1;
  22. while (curr <= b) {
  23. for (int i = 1; i <= 9; ++i)
  24. if (a <= i*curr && i*curr <= b)
  25. fout << i*curr << " ";
  26. curr = curr*10 + 1;
  27. }
  28. fout << "\n";
  29. }
  30. else {
  31. int x;
  32. fin >> x;
  33. assert(x <= 100);
  34.  
  35. for (int nrCif = 1; nrCif <= x; ++nrCif) {
  36. for (int cif = 1; cif <= 9; ++cif) {
  37. for (int i = 1; i <= nrCif; ++i)
  38. fout << cif;
  39. fout << " ";
  40. }
  41. }
  42.  
  43. fout << "\n";
  44. }
  45.  
  46. return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement