2961. Double Modular Exponentiation Medium

@problem@discussion
#Array#Math#Simulation



1/**
2 * [2961] Double Modular Exponentiation
3 *
4 * You are given a 0-indexed 2D array variables where variables[i] = [ai, bi, ci, mi], and an integer target.
5 * An index i is good if the following formula holds:
6 * 
7 * 	0 <= i < variables.length
8 * 	((ai^bi % 10)^ci) % mi == target
9 * 
10 * Return an array consisting of good indices in any order.
11 *  
12 * <strong class="example">Example 1:
13 * 
14 * Input: variables = [[2,3,3,10],[3,3,3,1],[6,1,1,4]], target = 2
15 * Output: [0,2]
16 * Explanation: For each index i in the variables array:
17 * 1) For the index 0, variables[0] = [2,3,3,10], (2^3 % 10)^3 % 10 = 2.
18 * 2) For the index 1, variables[1] = [3,3,3,1], (3^3 % 10)^3 % 1 = 0.
19 * 3) For the index 2, variables[2] = [6,1,1,4], (6^1 % 10)^1 % 4 = 2.
20 * Therefore we return [0,2] as the answer.
21 * 
22 * <strong class="example">Example 2:
23 * 
24 * Input: variables = [[39,3,1000,1000]], target = 17
25 * Output: []
26 * Explanation: For each index i in the variables array:
27 * 1) For the index 0, variables[0] = [39,3,1000,1000], (39^3 % 10)^1000 % 1000 = 1.
28 * Therefore we return [] as the answer.
29 * 
30 *  
31 * Constraints:
32 * 
33 * 	1 <= variables.length <= 100
34 * 	variables[i] == [ai, bi, ci, mi]
35 * 	1 <= ai, bi, ci, mi <= 10^3
36 * 	<font face="monospace">0 <= target <= 10^3</font>
37 * 
38 */
39pub struct Solution {}
40
41// problem: https://leetcode.com/problems/double-modular-exponentiation/
42// discuss: https://leetcode.com/problems/double-modular-exponentiation/discuss/?currentPage=1&orderBy=most_votes&query=
43
44// submission codes start here
45
46impl Solution {
47    pub fn get_good_indices(variables: Vec<Vec<i32>>, target: i32) -> Vec<i32> {
48        vec![]
49    }
50}
51
52// submission codes end
53
54#[cfg(test)]
55mod tests {
56    use super::*;
57
58    #[test]
59    fn test_2961() {
60    }
61}
62


Back
© 2025 bowen.ge All Rights Reserved.