-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path172(求阶乘尾部0个数).cpp
60 lines (52 loc) · 1.59 KB
/
172(求阶乘尾部0个数).cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// 给定数n,求n!中尾部零的个数
// 思路:零的个数和5有关,5/10/15/20/25都会产生一个零
// 而25/50/75会产生两个零;125/250等会产生三个零
// 因此个数 = n / 5 + n / 25 + n / 125 + ...
class Solution {
public:
int trailingZeroes(int n) {
int count = 0;
for(long long i=5; n / i; i *= 5)
count += n / i;
return count;
}
};
int main() {
Solution so;
vector<string> words;
words.push_back("oath");
words.push_back("eath");
char ch1[4] = {'o','a','a','n'};
char ch2[4] = {'e','t','a','e'};
char ch3[4] = {'i','h','k','r'};
char ch4[4] = {'i','f','l','v'};
vector<char> v1(ch1, ch1 + 4);
vector<char> v2(ch2, ch2 + 4);
vector<char> v3(ch3, ch3 + 4);
vector<char> v4(ch4, ch4 + 4);
vector<vector<char>> board;
board.push_back(v1);
board.push_back(v2);
board.push_back(v3);
board.push_back(v4);
int a[6] = {2, 3, 1, 2, 4, 8};
vector<int> v(a, a+6);
ListNode* head = new ListNode(1);
head->next = new ListNode(2);
head->next->next = new ListNode(3);
head->next->next->next = new ListNode(4);
head->next->next->next->next = new ListNode(5);
head->next->next->next->next->next = new ListNode(6);
ListNode* headA = new ListNode(3);
ListNode* headB = new ListNode(2);
headB->next = headA;
TreeNode* head1 = new TreeNode(1);
//head1->left = new TreeNode(2);
//head1->left = new TreeNode(2);
//head1->left->left = new TreeNode(2);
TreeLinkNode* root = new TreeLinkNode(1);
root->left = new TreeLinkNode(2);
root->right = new TreeLinkNode(3);
system("pause");
return 0;
}