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.

55 lines
1.3 KiB

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-5
bool isInRange(int n) {
//字典
unordered_map<int, int> _map = {{0, 1},
{1, 1},
{2, 1},
{3, 1},
{4, 1},
{5, 1}};
//小于100则返回false
if (n < 100) return false;
//判断百位
if (_map.count(n / 100) < 0) return false;
//判断十位
n = n % 100;
if (_map.count(n / 10) < 0) return false;
//判断个位
n = n % 10;
if (_map.count(n) < 0) return false;
return true;
}
//是不是0-5都有
bool include0To5(int a, int b) {
unordered_map<int, int> _zeroFive;
while (a) {
_zeroFive[a % 10]++;
a /= 10;
}
while (b) {
_zeroFive[b % 10]++;
b /= 10;
}
for (int i = 0; i <= 5; ++i) {
if (_zeroFive.count(i) == 0) return false;
}
return true;
}
int main() {
for (int i = 50; i <= 250; ++i) {
if (isInRange(i * 2) && isInRange(i * 4) && include0To5(i * 2, i * 4)) {
cout << i << " " << i << endl;
cout << i * 2 << " " << i * 4 << endl;
}
}
return 0;
}