55 lines
1.3 KiB
C++
55 lines
1.3 KiB
C++
#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;
|
||
}
|