3 22 10 3 7 0 1 2 10 1 1 25 16 3 A B CSample Output
110
give me the bomb please
CCB
//Huge input, scanf is recommended.
题目大意: 中文题自己看→_→ ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
解题思路: 500位不能用N的倍数去一个一个判断。要用bfs一个一个数地加。每加一个数要%N一次防爆。因为每个数都是余数,舍掉的N的倍数的前缀没有影响,故余数相同的情况是同一种情况,用vis记录并判重。如第二个测试数据,余数永远是1,不可能除尽2,若不用余数判重,必须算到501位才能得出结果。
ac代码:
#include
#include
#include
#include
#include
using namespace std;
int T,N,C,M;
int k;
char c;
int a[16];
bool vis[10000];
string ans;
struct node
{
int num;
string str;
int len;
node(int n=0,string s="",int l=0)
{
num = n;
str = s;
len = l;
}
};
char toChar(int x)
{
if(x<10)
return x + '0';
else
return x - 10 + 'A';
}
void bfs()
{
queue que;
node p,pp;
for(int i=0;i500)
continue;
for(int i=0;i>T;
while(T--)
{
k = 0;//判断M个数中有没有0
memset(vis,0,sizeof(vis));
cin>>N>>C;
cin>>M;
for(int i=0;i>c;
if(c>='0'&&c<='9')
a[i] = c - '0';
else
a[i] = c - 55;
if(!a[i])
k = 1; //有0
}
if(!N&&k)//N==0且有0
{
cout<<0<