本文整理汇总了C#中BigInteger.GetLength方法的典型用法代码示例。如果您正苦于以下问题:C# BigInteger.GetLength方法的具体用法?C# BigInteger.GetLength怎么用?C# BigInteger.GetLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BigInteger
的用法示例。
在下文中一共展示了BigInteger.GetLength方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main()
{
int rows = int.Parse(Console.ReadLine());
int cols = int.Parse(Console.ReadLine());
long verticallyStart = long.Parse(Console.ReadLine());
long horizontallyStart = long.Parse(Console.ReadLine());
BigInteger n = verticallyStart * horizontallyStart;
BigInteger tempStart = n;
BigInteger[,] matrix = new BigInteger[rows, cols];
for (int i = 0; i < matrix.GetLength(0); i++)
{
for (int j = 0; j < matrix.GetLength(1); j++)
{
matrix[i, j] = tempStart;
tempStart += verticallyStart;
}
n += horizontallyStart;
tempStart = n;
verticallyStart++;
}
for (int i = 0; i < matrix.GetLength(0); i++)
{
for (int j = 0; j < matrix.GetLength(1); j++)
{
Console.Write("{0} ", matrix[i, j]);
}
Console.WriteLine();
}
}
示例2: Main
static void Main()
{
string input = Console.ReadLine();
BigInteger[,] combCount = new BigInteger[input.Length / 2 + 1, input.Length]; //combinations count with number open brackets
combCount[1, 0] = 1;
for (int c = 1; c < combCount.GetLength(1); c++)
{
for (int r = 0; r < combCount.GetLength(0); r++)
{
if (combCount[r, c - 1] > 0)
{
if (input[c] == '(' && r + 1 < combCount.GetLength(0))
{
combCount[r + 1, c] += combCount[r, c - 1];
}
else if (input[c] == ')' && r - 1 >= 0)
{
combCount[r - 1, c] += combCount[r, c - 1];
}
else if(input[c] == '?' && r + 1 < combCount.GetLength(0))
{
combCount[r + 1, c] += combCount[r, c - 1]; ;
}
if (input[c] == '?' && r - 1 >= 0)
{
combCount[r - 1, c] += combCount[r, c - 1]; ;
}
}
}
}
Console.WriteLine(combCount[0, combCount.GetLength(1) - 1]);
}
示例3: CreateMatrix
private static BigInteger[,] CreateMatrix(int Rows, int Cols)
{
BigInteger[,] matrix = new BigInteger[Rows, Cols];
for (int row = matrix.GetLength(0) - 1; row >= 0; row--)
{
for (int col = 0; col < matrix.GetLength(1); col++)
{
int rowPower = matrix.GetLength(0) - row - 1;
int colPower = col;
if (row == Rows - 1 && col == 0)
{
matrix[row, col] = 1;
}
else if (row == Rows - 1)
{
matrix[row, col] = (BigInteger)Math.Pow(2, colPower);
}
else if (col == 0)
{
matrix[row, col] = (BigInteger)Math.Pow(2, rowPower);
}
else
{
matrix[row, col] = matrix[row, col - 1] + matrix[row + 1, col];
}
}
}
return matrix;
}
示例4: printMatrix
static void printMatrix(BigInteger[,] matrix)
{
for (int i = 0; i < matrix.GetLength(0); i++)
{
for (int j = 0; j < matrix.GetLength(1); j++)
{
Console.Write("{0, 5} ", matrix[i, j]);
}
Console.WriteLine();
}
}
示例5: CalcualateSum
static BigInteger CalcualateSum(BigInteger[,] matrix, int moves, int[] codes)
{
int rows = matrix.GetLength(0);
int cols = matrix.GetLength(1);
int devider = Math.Max(rows, cols);
BigInteger sum = 0;
int currentRow = rows - 1;
int currentCol = 0;
for (int i = 0; i < codes.Length; i++)
{
int row = codes[i] / devider;
int col = codes[i] % devider;
if (currentRow > row)
{
for (int r = currentRow; r >= row; r--)
{
sum += matrix[r, currentCol];
matrix[r, currentCol] = 0;
}
currentRow = row;
}
else
{
for (int r = currentRow; r <= row; r++)
{
sum += matrix[r, currentCol];
matrix[r, currentCol] = 0;
}
currentRow = row;
}
if (currentCol > col)
{
for (int c = currentCol; c >= col; c--)
{
sum += matrix[currentRow, c];
matrix[currentRow, c] = 0;
}
currentCol = col;
}
else
{
for (int c = currentCol; c <= col; c++)
{
sum += matrix[currentRow, c];
matrix[currentRow, c] = 0;
}
currentCol = col;
}
}
return sum;
}
示例6: CalculateSum
private static BigInteger CalculateSum(bool[,] visitedCells, BigInteger[,] matrix)
{
BigInteger sum = 0;
for (int row = 0; row < matrix.GetLength(0); row++)
{
for (int col = 0; col < matrix.GetLength(1); col++)
{
if (visitedCells[row, col])
{
sum += matrix[row, col];
}
}
}
return sum;
}
示例7: GetFilledMatrix
internal static BigInteger[,] GetFilledMatrix(byte matrixRows, byte matrixCols)
{
BigInteger[,] matrix = new BigInteger[matrixRows, matrixCols];
for (int row = matrix.GetLength(0) - 1; row >= 0; row--)
{
for (int col = 0; col < matrix.GetLength(1); col++)
{
matrix[row, col] = (BigInteger)Math.Pow(2, col + matrix.GetLength(0) - row - 1);
}
}
return matrix;
}
示例8: CountWays
private static BigInteger CountWays(BigInteger[,] field)
{
for (int row = 0; row < field.GetLength(0); row++)
{
for (int col = 0; col < field.GetLength(1); col++)
{
if (row == 0 && col == 0)
{
field[0, 0] = 1;
continue;
}
if (field[row, col] == -1)
{
field[row, col] = 0;
continue;
}
if (row == 0)
{
field[0, col] = field[0, col - 1];
continue;
}
if (col == 0)
{
field[row, 0] = field[row - 1, 0];
continue;
}
field[row, col] = field[row - 1, col] + field[row, col - 1];
}
}
return field[finalRow, finalCol];
}
示例9: Main
static void Main()
{
string input = Console.ReadLine();
BigInteger[][] table = new BigInteger[input.Length + 2][];
table[1] = new BigInteger[input.Length + 1];
table[1][1] = 1;
for (int row = 2; row < table.GetLength(0); row++)
{
table[row] = new BigInteger[input.Length + 1];
for (int col = 1; col < table[row].Length; col++)
{
if (row < table.Length && col < table[row].Length - 1)
{
if (input[row - 2] == '?')
{
table[row][col] = table[row - 1][col - 1] + table[row - 1][col + 1];
}
if (input[row - 2] == '(')
{
table[row][col] = table[row - 1] [col - 1];
}
if (input[row - 2] == ')')
{
table[row][ col] = table[row - 1][col + 1];
}
}
}
table[row - 1] = null;
}
//Print(table);
Console.WriteLine(table[table.Length - 1][ 1]);
}
示例10: Main
static void Main()
{
int matrixRows = int.Parse(Console.ReadLine());
int matrixCols = int.Parse(Console.ReadLine());
//======================
int movesNumber = int.Parse(Console.ReadLine());
string[] codes = Console.ReadLine().Split(' ');
int[,] points = new int[movesNumber+1, 2];
points[0, 0] = matrixRows - 1;
points[0, 1] = 0;
for (int i = 0; i < codes.Length; i++)
{
points[i + 1, 0] = int.Parse(codes[i]) / Math.Max(matrixRows, matrixCols);
points[i + 1, 1] = int.Parse(codes[i]) % Math.Max(matrixRows, matrixCols);
}
//=======================
BigInteger [,] matrix = new BigInteger[matrixRows, matrixCols];
for (int i = matrix.GetLength(0) - 1; i >= 0; i--)
{
for (int j = 0; j < matrix.GetLength(1); j++)
{
matrix[i, j] = (BigInteger)Math.Pow(2, j + matrix.GetLength(0) - i - 1);
}
}
//========================
int fromRow, fromCol, toRow, toCol;
BigInteger collectedPoints = 0;
for (int i = 0; i < points.GetLength(0) - 1; i++)
{
fromRow = points[i, 0];
fromCol = points[i, 1];
toRow = points[i + 1, 0];
toCol = points[i + 1, 1];
if (fromCol < toCol)
{
for (int j = fromCol; j <= toCol; j++)
{
collectedPoints += matrix[fromRow, j];
matrix[fromRow, j] = 0;
//Console.WriteLine("row={0}, col={1}", fromRow, j);
}
}
else
for (int j = fromCol; j >= toCol; j--)
{
collectedPoints += matrix[fromRow, j];
matrix[fromRow, j] = 0;
//Console.WriteLine("row={0}, col={1}", fromRow, j);
}
if (fromRow < toRow)
{
for (int j = fromRow; j <= toRow; j++)
{
collectedPoints += matrix[j, toCol];
matrix[j, toCol] = 0;
//Console.WriteLine("row={0}, col={1}", j, toCol);
}
}
else
{
for (int j = fromRow; j >= toRow; j--)
{
collectedPoints += matrix[j, toCol];
matrix[j, toCol] = 0;
//Console.WriteLine("row={0}, col={1}", j, toCol);
}
}
//printMatrix(matrix);
//Console.WriteLine("Result after point {0} = {1}", i + 1, collectedPoints);
}
Console.WriteLine("{0:D2}", collectedPoints);
}
示例11: PrintMatrix
private static void PrintMatrix(BigInteger[,] matrix)
{
for (int row = 0; row < matrix.GetLength(0); row++)
{
for (int col = 0; col < matrix.GetLength(1); col++)
{
Console.Write("{0}".PadRight(5), matrix[row, col]);
}
Console.WriteLine();
}
}