default
\n\n# Code\n\nuse std::collections::HashMap;\n\nfn gcd(mut a: i32, mut b: i32) -> i32\n{\n    loop\n    {\n        let z = a % b;\n\n        if (z == 0)\n      
\n\n# Code\n```\nuse std::collections::HashMap;\n\nfn gcd(mut a: i32, mut b: i32) -> i32\n{\n    loop\n    {\n        let z = a % b;\n\n        if (z == 0)\n        {\n            break;\n        }\n\n        a = b;\n        b = z;\n    }\n\n    return b;\n}\n\nimpl Solution\n{\n    pub fn count_pairs(nums: Vec<i32>, k: i32) -> i64\n    {\n        let mut count = vec![0; 100000 + 1];\n        let mut ans = 0;\n        let mut div_list = HashMap::new();\n        for e in nums\n        {\n            let g = gcd(e, k);\n            let g2 = k / g;\n            \n            ans += count[g2 as usize];\n\n            if div_list.get(&g).is_none()\n            {\n                let mut divs = vec![];\n                let mut x = 1;\n                while (x * x <= g)\n                {\n                    if g % x == 0\n                    {\n                        divs.push(x as usize);\n                        count[x as usize] += 1;\n\n                        if x * x != g\n                        {\n                            divs.push((g / x) as usize);\n                            count[(g / x) as usize] += 1;\n                        }\n                    }\n\n                    x += 1;\n                }\n\n                div_list.insert(g, divs);\n            }\n            else\n            {\n                for &x in div_list.get(&g).unwrap()\n                {\n                    count[x] += 1;\n                }\n            }\n        }\n\n        return ans;\n    }\n}\n```
['Rust']