import math


def get_dimensions(rows, size):
    """
    Count number of cols and rows for topology
    :param rows: number of rows
    :param size: number of process
    :return: number of rows and cols
    """
    comm_cols = int(math.sqrt(rows))

    while comm_cols > 1 and size % comm_cols:
        comm_cols -= 1

    return int(size / comm_cols), comm_cols