B - Fair Numbers
暴力求解
代码如下
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool exam(ll n)
{
ll i = n;
while (i)
{
if (i % 10 != 0 && n % (i % 10) != 0) //单位为0时不用除
return false;
i /= 10;
}
return true;
}
int main()
{
ll t;
cin >> t;
while (t--)
{
ll n;
cin >> n;
for (ll i = n; i < 1e20; i++)
{
if (exam(i))
{
cout << i << endl;
break;
}
}
}
}