2961.双模幂运算
链接:2961.双模幂运算
难度:Medium
标签:数组、数学、模拟
简介:返回一个由 好下标 组成的数组,顺序不限 。
题解 1 - python
- 编辑时间:2024-07-30
- 执行用时:44ms
- 内存消耗:16.5MB
- 编程语言:python
- 解法介绍:枚举每一个块与另一个块是否位置产生交集。
class Solution:
def getGoodIndices(self, variables: List[List[int]], target: int) -> List[int]:
def f(i: int) -> int:
a, b, c, m = variables[i]
return pow(pow(a, b, 10), c, m)
return [i for i in range(len(variables)) if f(i) == target]