fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. int n,i,j,s,y,x1;
  9. scanf("%d%d",&n,&s);
  10. int b[n];
  11. memset(b,0,n*sizeof(int));
  12. x1=n;
  13. j=0;
  14. while(s>0)
  15. {
  16. y=j%n;
  17. if(j!=n-1)
  18. {
  19. b[y]++;
  20. s--;
  21. j++;
  22. }
  23. else
  24. {
  25. b[y]++;
  26. s--;
  27. j=0;
  28. n--;
  29. }
  30. }
  31. for(i=0;i<x1;++i)
  32. {
  33. printf("%d ",b[i]);
  34. }
  35. return 0;
  36. }
Success #stdin #stdout 0s 3100KB
stdin
4 9
stdout
3 3 2 1