Result: Accepted
Time: 6ms
Memory: 1712kB
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
int i,n,j,row;
int cnt[1001]={0,1};
int now;
for(i=2;i<1001;i++){
cnt[i]=cnt[i-1]+i-1;
}
while(cin>>row){
for(i=1;i<=row;i++){
now=cnt[i];
cout<<now;
if(i==row) cout<<endl;
else cout<<' ';
for(j=2;j<=row-i+1;j++){
now+=j+i-1;
cout<<now;
if(j==row-i+1)cout<<endl;
else cout<<' ';
}
}
}
return 0;
}