You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
#include <bits/stdc++.h>
|
|
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
题目:求0—7所能组成的奇数个数。 (不可重复 0不能做首位) 46972
|
|
|
|
|
思路: 0-7不能重复 统计1位,2位,3位, 4位, 5位, 6位,7位,8位,每个位数的奇数个数
|
|
|
|
|
1位 4 (1,3,5,7)
|
|
|
|
|
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;
|
|
|
|
|
}
|