The 6th Blue Bridge Cup Group B C/C++_Number of lottery tickets

Number of lotteries

Some people are very superstitious about numbers, such as numbers with "4", and think that it is homophonic with "death", which is considered unlucky.
Although these claims are pure nonsense, but sometimes also cater to the needs of the public. The lottery number of a lottery is 5 digits (10000-99999),
It is required that the number with "4" does not appear in it. The organizer asks you to calculate the maximum number of lottery coupons that can be issued if any two lottery coupons are not duplicated.

Please submit this number (an integer) without any superfluous or descriptive text.

.The day after tomorrow, the game will be played again! This question is not difficult, it uses violence directly, but after thinking about it carefully, there is still some problem when writing the judgment. It's really important to do the math of the algorithm problem. You don't need to write any code at all. A simple permutation and combination comes out: 8*9*9*9*9=52488!

.

/*10000-99999*/
#include<iostream>
using namespace std;
bool Ju (int i) {
	int temp;
	while (i>0) {
		temp = i % 10;//I understand wrong here, it should not be i % 4!!!
		i /= 10;
		if (temp == 4) {
			return 0;
			break;
		}
	}
	return 1;//If the condition is met, return 1
}
int main() {
	int account = 0;
	for (int i = 10000; i <= 99999; i++) {//The number 99999 is written as 9999
		if (Ju(i)) {
			account++;
		}
	}
	cout << account << endl;
	return 0;
}

.

.

.

.

.

.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325693678&siteId=291194637