#include<bits/stdc++.h>

using namespace std;

int main(){

int n,k;
cin>>n>>k;
int sum=0;
int a[k+1]={0};
int i=1;
int candy=1;

while(i){
  if(i == k+1)
  i = 1;
  
  if((n-sum)<=candy) {
      arr[i]+=(n-sum);
      break;
  }
  
  arr[i]+=candy;
  sum+=candy;
  candy++;
  i++;
}

for(int j=1;j<=k;j++){
  cout<<a[j]<<" ";
}

return 0;
}




Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: