还是nwu17冬03-搜索专题
H - Find The Multiple
提示:本题采用Special Judge,你无需输出所有符合条件的m,你只需要输出任一符合条件的m即可。
2 6 19 0
10 100100100100100100 111111111111111111
这题。。题目中说m不多于100位,吓得我以为要用数组模拟大数,其实long long就过了。。
按位dfs。条件是*10 和*10+1
#include <iostream>
#include <queue>
using namespace std;
typedef long long ll;
int main()
{
int n;
while (cin >> n && n > 0)
{
queue<ll> que;
ll ans = 1;
que.push(ans);
while (que.size())
{
ll t = que.front();
//cout << t << endl;
que.pop();
if (t % n == 0)
{
ans = t;
break;
}
que.push(t * 10);
que.push(t * 10 + 1);
}
cout << ans << endl;
}
}
I - The Game
A game of Renju is played on a 19*19 board by two players. One player uses black stones and the other uses white stones. The game begins in an empty board and two play