Răspuns:
#include <iostream>
#include <math.h>
using namespace std;
int main()
{ int n,i,np,j,k,p=0;
cin>>n;
while(k<n){p++;
k=p*p;}
p--;
k=p*p;
np=n-k;
cout<<np<<"\n";
for(i=1;i<=p;i++)
{for(j=1;j<=p;j++) {cout<<k<<" ";
k--;}
cout<<"\n";}
return 0;
}