1.
#include <iostream>
using namespace std;
int a[20][40];
int main() {
int n,k,i,j;
cin>>n>>k;
for (i=1; i<=k*n; i++) {
a[1][i]=(i-1)/k+1;
}
for (i=2; i<=n; i++) {
for (j=1; j<=n*k; j++) {
a[i][j]=a[i-1][j]+1;
}
}
for (i=1; i<=n; i++) {
for (j=1; j<=n*k; j++) {
cout<<a[i][j]<<" ";
}
cout<<endl;
}
return 0;
}
2.
#include <iostream>
using namespace std;
int main() {
unsigned int a, b, c=0;
cin>>a>>b;
cout<<b<<" "<<a<< " ";
while(c!=1) {
c=3*a-b;
cout<<c<<" ";
b=a;
a=c;
}
cout<<1;
return 0;
}