Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2020
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. #include <fstream>
  2. #include <algorithm>
  3. using namespace std;
  4. ifstream f("egale.in");
  5. ofstream g("egale.out");
  6. long long c,p,x,i,a,o,cnt1,cnt2,ucf,b,s,o1,cnt,j;
  7. int main()
  8. {
  9.  
  10. f>>c;
  11. if(c==2)
  12. {
  13. f>>a;
  14. p=1;x=1;
  15. while(p<=a)
  16. {
  17. for(i=1;i<=9;i++)
  18. {
  19. for(j=1;j<=p;j++)
  20. g<<i;
  21. g<<" ";
  22. }
  23. p++;
  24.  
  25. }
  26. }
  27. else
  28. {
  29. f>>a>>b;
  30. s=a+b;
  31. a=min(a,b);
  32. b=s-a;
  33. o=a;o1=b;
  34. cnt=0;cnt2=0;
  35.  
  36. while(o!=0)
  37. {
  38. cnt++;
  39. o/=10;
  40. }
  41. while(o1!=0)
  42. {
  43. cnt2++;
  44. o1/=10;
  45. }
  46. for(i=1;i<=cnt;i++)
  47. x=x*10+1;
  48.  
  49. for(j=cnt;j<=cnt2;j++)
  50. {
  51. for(i=1;i<=9;i++)
  52. {
  53.  
  54. if(x*i<=b&&x*i>=a)
  55. g<<x*i<<" ";
  56.  
  57.  
  58. }
  59. x=x*10+1;
  60. }
  61. }
  62.  
  63. f.close();
  64. g.close();
  65. return 0;
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement