a53

HappyNY2018

a53
Jan 4th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. int n, m, r, c, x, i, j;
  5. class OutParser
  6. {
  7. private:
  8. char *buff;
  9. int sp;
  10.  
  11. void write_ch(char ch)
  12. {
  13. if (sp == 50000)
  14. {
  15. fwrite(buff, 1, 50000, stdout);
  16. sp = 0;
  17. buff[sp++] = ch;
  18. }
  19. else
  20. {
  21. buff[sp++] = ch;
  22. }
  23. }
  24.  
  25.  
  26. public:
  27. OutParser() {
  28. buff = new char[50000]();
  29. sp = 0;}
  30. ~OutParser()
  31. {
  32. fwrite(buff, 1, sp, stdout);
  33. fclose(stdout);
  34. }
  35.  
  36. OutParser& operator << (int vu32)
  37. {
  38. if (vu32 <= 9)
  39. {
  40. write_ch(vu32 + '0');
  41. }
  42. else
  43. {
  44. (*this) << (vu32 / 10);
  45. write_ch(vu32 % 10 + '0');
  46. }
  47. return *this;
  48. }
  49.  
  50. OutParser& operator << (long long vu64)
  51. {
  52. if (vu64 <= 9)
  53. {
  54. write_ch(vu64 + '0');
  55. }
  56. else
  57. {
  58. (*this) << (vu64 / 10);
  59. write_ch(vu64 % 10 + '0');
  60. }
  61. return *this;
  62. }
  63.  
  64. OutParser& operator << (char ch)
  65. {
  66. write_ch(ch);
  67. return *this;
  68. }
  69. OutParser& operator << (const char *ch)
  70. {
  71. while (*ch)
  72. {
  73. write_ch(*ch);
  74. ++ch;
  75. }
  76. return *this;
  77. }
  78. };
  79. int main()
  80. {
  81. OutParser fout;
  82. cin>>n>>m;
  83. for (i=1; i<=n; ++i)
  84. {
  85. cin>>x;
  86. r=x%m;
  87. c=x/m;
  88. for (j=1; j<=m-r; ++j)
  89. fout<<c<<" ";
  90. for (j=1; j<=r; ++j)
  91. fout<<c+1<<" ";
  92. fout<<"\n";
  93. }
  94. return 0;
  95. }
Add Comment
Please, Sign In to add comment