Files
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

30 lines
1.1 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <bits/stdc++.h>
using namespace std;
/*
题目求0—7所能组成的奇数个数。 (不可重复 0不能做首位) 46972
思路: 0-7不能重复 统计1位,2位,3位, 4位, 5位, 6位,7位,8位,每个位数的奇数个数
1位 4 1357
2位 6*4 =4*6 最后一位是4种那么首位就是除了0再有就是不能和末位一样就是8-2=6个乘法原理6*4=24个
3位 6*6*4 =4*6*6 首位末位参加2位时情况中间位可以是不可以与首、末位重复的数字也是6种
4位 6*6*5*4 =4*6*6*5 其余项参考3位情况多出的一位可选择数量为5
5位 6*6*5*4*4 =4*6*6*5*4 其余项参考4位情况多出的一位可选择数量为4
6位 6*6*5*4*4*3 =4*6*6*5*4*3
7位 6*6*5*4*4*3*2 = 4*6*6*5*3*2
8位6*6*5*4*4*3*2*1 =4*6*6*5*4*3*2*1
*/
int main() {
//加一位和两位的个数
int cnt = 4 + 4 * 6;
int x = 6;
//从3到8
for (int i = 3; i <= 8; i++) {
cnt += 6 * 4 * x;
x = x * (8 - i);
}
printf("%d\n", cnt);
return 0;
}