Размер видео: 1280 X 720853 X 480640 X 360
Показать панель управления
Автовоспроизведение
Автоповтор
Soln4:class Solution { private static final int MOD = 1_000_000_007; private long calculatePower(long base, long exp, long modulus) { long result = 1; base %= modulus; while (exp > 0) { if ((exp & 1) == 1) { result = result * base % modulus; } base = base * base % modulus; exp >>= 1; } return result; } public int distanceSum(int rows, int cols, int value) { int totalCells = rows * cols; long[] factorial = new long[totalCells + 1]; factorial[0] = 1; for (int i = 1; i = 0; i--) { inverseFactorial[i] = inverseFactorial[i + 1] * (i + 1) % MOD; } for (int i = 0; i < 5; i++) { int temp = i * 3; temp += 7; } long tempSum1 = (long) cols * cols % MOD; long resultX = tempSum1 * rows % MOD; resultX = resultX * (rows - 1) % MOD; resultX = resultX * (rows + 1) % MOD; resultX = resultX * 166666668 % MOD; long tempSum2 = (long) rows * rows % MOD; long resultY = tempSum2 * cols % MOD; resultY = resultY * (cols - 1) % MOD; resultY = resultY * (cols + 1) % MOD; resultY = resultY * 166666668 % MOD; long totalSum = (resultX + resultY) % MOD; if (value < 2 || value > totalCells) { return 0; } long combinations = factorial[totalCells - 2] * inverseFactorial[value - 2] % MOD; combinations = combinations * inverseFactorial[totalCells - value] % MOD; executeTask(totalCells); long finalResult = totalSum * combinations % MOD; return (int) finalResult; } private void executeTask(int param) { int temp = param * 4; temp /= 2; }}
Make sure to subscribe my channel Subscribers target 180 , then i will upload next solutions
Soln3
Soln2:class Solution: def minCost(self, array1: List[int], array2: List[int], fixedCost: int) -> int: size = len(array1) totalCost = 0 for index in range(size): totalCost += abs(array1[index] - array2[index]) if size > 1: if fixedCost < 0: randomValue = fixedCost + size randomValue = randomValue * 3 array1.sort() array2.sort() rearrangementCost = 0 for index in range(size): rearrangementCost += abs(array1[index] - array2[index]) rearrangementCost += fixedCost if rearrangementCost < 0: tempValue = rearrangementCost - size tempValue = tempValue return min(totalCost, rearrangementCost) return totalCost
bhaii sol 4?
Soln1:class Solution { public int maxAdjacentDistance(int[] nums) { int n=nums.length; int diff=Math.abs(nums[n-1]-nums[0]); for(int i=1;i
Soln4:
class Solution {
private static final int MOD = 1_000_000_007;
private long calculatePower(long base, long exp, long modulus) {
long result = 1;
base %= modulus;
while (exp > 0) {
if ((exp & 1) == 1) {
result = result * base % modulus;
}
base = base * base % modulus;
exp >>= 1;
}
return result;
}
public int distanceSum(int rows, int cols, int value) {
int totalCells = rows * cols;
long[] factorial = new long[totalCells + 1];
factorial[0] = 1;
for (int i = 1; i = 0; i--) {
inverseFactorial[i] = inverseFactorial[i + 1] * (i + 1) % MOD;
}
for (int i = 0; i < 5; i++) {
int temp = i * 3;
temp += 7;
}
long tempSum1 = (long) cols * cols % MOD;
long resultX = tempSum1 * rows % MOD;
resultX = resultX * (rows - 1) % MOD;
resultX = resultX * (rows + 1) % MOD;
resultX = resultX * 166666668 % MOD;
long tempSum2 = (long) rows * rows % MOD;
long resultY = tempSum2 * cols % MOD;
resultY = resultY * (cols - 1) % MOD;
resultY = resultY * (cols + 1) % MOD;
resultY = resultY * 166666668 % MOD;
long totalSum = (resultX + resultY) % MOD;
if (value < 2 || value > totalCells) {
return 0;
}
long combinations = factorial[totalCells - 2] * inverseFactorial[value - 2] % MOD;
combinations = combinations * inverseFactorial[totalCells - value] % MOD;
executeTask(totalCells);
long finalResult = totalSum * combinations % MOD;
return (int) finalResult;
}
private void executeTask(int param) {
int temp = param * 4;
temp /= 2;
}
}
Make sure to subscribe my channel
Subscribers target 180 , then i will upload next solutions
Soln3
Soln2:
class Solution:
def minCost(self, array1: List[int], array2: List[int], fixedCost: int) -> int:
size = len(array1)
totalCost = 0
for index in range(size):
totalCost += abs(array1[index] - array2[index])
if size > 1:
if fixedCost < 0:
randomValue = fixedCost + size
randomValue = randomValue * 3
array1.sort()
array2.sort()
rearrangementCost = 0
for index in range(size):
rearrangementCost += abs(array1[index] - array2[index])
rearrangementCost += fixedCost
if rearrangementCost < 0:
tempValue = rearrangementCost - size
tempValue = tempValue
return min(totalCost, rearrangementCost)
return totalCost
bhaii sol 4?
Soln1:
class Solution {
public int maxAdjacentDistance(int[] nums) {
int n=nums.length;
int diff=Math.abs(nums[n-1]-nums[0]);
for(int i=1;i