#include<iostream>
#include<queue>
using namespace std;
int x(int n,int m)
{
int temp = n*m;
while (temp)
{
if (temp % 10 >= 2)
return 0;
temp=temp/10;
}
return 1;
}
int main711()//解法1
{
int n;
while (cin >> n)
{
int m;
for (m = 1; m++;)
if (x(n, m))
{
cout << n << "," << m*n << endl;
break;
}
}
return 0;
}
int main()//利用深度优先搜索 解法2
{
int n;
while (cin >> n)
{
queue<int>a;
a.push(1);
while (!a.empty())
{
int temp = a.front();
a.pop();
if (temp%n == 0)
{
cout << n << "," << temp << endl;
break;
}
a.push(temp * 10);
a.push(temp * 10+1);
}
}
return 0;
}
0711编程之美找符合条件的整数
最新推荐文章于 2022-05-03 20:44:20 发布