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.

29 lines
744 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include <bits/stdc++.h>
using namespace std;
/*
题目求0—7所能组成的奇数个数。 (可重复 0不能做首位)
思路: 0-7能重复 统计1位,2位,3位, 4位, 5位, 6位,7位,8位,每个位数的奇数个数
1位 4 1357
2位 7*4 =4*7 最后一位是4种那么首位就是除了0就是8-1=7个乘法原理7*4=28个
3位 7*4*8
4位 7*4*8*8
5位 7*4*8*8*8
6位 7*4*8*8*8*8
7位 7*4*8*8*8*8*8
8位 7*4*8*8*8*8*8*8
*/
int main() {
//加一位和两位的个数
int cnt = 4 + 4 * 7;
int x = 8;
//从3到8
for (int i = 3; i <= 8; i++) {
cnt += 7 * 4 * x;
x = x * 8;
}
printf("%d\n", cnt);
return 0;
}