problemscpp
A collection of my answers to algorithm problems in c++.
| 函数
leetcode::find_palindrome_with_fixed_length 命名空间参考

  1. 找到指定长度的回文数
更多...

class  Solution
 

函数

unsigned long long qmi (unsigned long long m, unsigned long long k)
 
 TEST (find_palindrome_with_fixed_length, case1)
 
 TEST (find_palindrome_with_fixed_length, case2)
 
 TEST (find_palindrome_with_fixed_length, case4)
 
 TEST (find_palindrome_with_fixed_length, case5)
 
 TEST (find_palindrome_with_fixed_length, case7)
 

详细描述

  1. 找到指定长度的回文数

函数说明

◆ qmi()

unsigned long long leetcode::find_palindrome_with_fixed_length::qmi ( unsigned long long  m,
unsigned long long  k 
)

在文件 leetcode.cpp5080 行定义.

5080 {
5081 unsigned long long res = 1;
5082 unsigned long long t = m;
5083 while(k != 0U) {
5084 if((k & 1) != 0U) {
5085 res = res * t;
5086 }
5087 t = t * t;
5088 k >>= 1;
5089 }
5090 return res;
5091 }

被这些函数引用 leetcode::find_palindrome_with_fixed_length::Solution::kthPalindrome().

◆ TEST() [1/5]

leetcode::find_palindrome_with_fixed_length::TEST ( find_palindrome_with_fixed_length  ,
case1   
)

在文件 leetcode_test.cpp2477 行定义.

2477 {
2478 vector queries = {1, 2, 3, 4, 5, 90};
2479 const vector<long long> output = {101, 111, 121, 131, 141, 999};
2480 ASSERT_EQ(output, Solution::kthPalindrome(queries, 3));
2481 }

引用了 leetcode::find_palindrome_with_fixed_length::Solution::kthPalindrome().

◆ TEST() [2/5]

leetcode::find_palindrome_with_fixed_length::TEST ( find_palindrome_with_fixed_length  ,
case2   
)

在文件 leetcode_test.cpp2483 行定义.

2483 {
2484 vector queries = {2, 4, 6};
2485 const vector<long long> output = {1111, 1331, 1551};
2486 ASSERT_EQ(output, Solution::kthPalindrome(queries, 4));
2487 }

引用了 leetcode::find_palindrome_with_fixed_length::Solution::kthPalindrome().

◆ TEST() [3/5]

leetcode::find_palindrome_with_fixed_length::TEST ( find_palindrome_with_fixed_length  ,
case4   
)

在文件 leetcode_test.cpp2489 行定义.

2489 {
2490 vector queries = {10};
2491 const vector<long long> output = {191};
2492 ASSERT_EQ(output, Solution::kthPalindrome(queries, 3));
2493 }

引用了 leetcode::find_palindrome_with_fixed_length::Solution::kthPalindrome().

◆ TEST() [4/5]

leetcode::find_palindrome_with_fixed_length::TEST ( find_palindrome_with_fixed_length  ,
case5   
)

在文件 leetcode_test.cpp2495 行定义.

2495 {
2496 vector queries = {9};
2497 const vector<long long> output = {10801};
2498 ASSERT_EQ(output, Solution::kthPalindrome(queries, 5));
2499 }

引用了 leetcode::find_palindrome_with_fixed_length::Solution::kthPalindrome().

◆ TEST() [5/5]

leetcode::find_palindrome_with_fixed_length::TEST ( find_palindrome_with_fixed_length  ,
case7   
)

在文件 leetcode_test.cpp2501 行定义.

2501 {
2502 vector queries = {60};
2503 const vector<long long> output = {15951};
2504 ASSERT_EQ(output, Solution::kthPalindrome(queries, 5));
2505 }

引用了 leetcode::find_palindrome_with_fixed_length::Solution::kthPalindrome().