fork(2) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. int a,b;
  6. cin >> a >> b;
  7. cout << a*b << "\n";
  8. for(int i =0; i < a; i++) {
  9. for(int j =0; j < b; j++) {
  10. cout << i*b+b-j;
  11. if(j < b-1) cout << " ";}
  12. cout << ((i == a-1)?"\n":" ");}
  13. return 0;}
Success #stdin #stdout 0s 3344KB
stdin
3 2
stdout
6
2 1 4 3 6 5