#include #include using namespace std; const int MAXSIZE = 5000; long matrix[MAXSIZE][MAXSIZE]; int rows, cols; int rowFactors[100]; int colFactors[100]; int nr, nc; long gcd(long a, long b) { if (b == 0) return a; else return gcd(b, a%b); } void calcFactors(int val, int factors[], int &num) { num = 0; int f = 1; while (f <= val/2) { if (val%f == 0) factors[num++] = f; f++; } factors[num++] = val; } long calcFactors(long val) { long num = 0; long f = 1; long sq = (long) sqrt((double) val); while (f <= sq) { if (val%f == 0) num+=2; f++; } f--; if (f*f == val) num--; return num; } int isTensor(int r, int c) { if (r==1 && c==1) return false; if (r==rows && c==cols) return false; int i, j, k, l; long val1 = matrix[0][0]; long gcd1 = matrix[0][0]; for(i=0; i> rows >> cols; while (rows != 0) { for(i=0; i> matrix[i][j]; } } calcFactors(rows, rowFactors, nr); calcFactors(cols, colFactors, nc); int numTensor=0; for(i=0; i> rows >> cols; } }