本文共 659 字,大约阅读时间需要 2 分钟。
题目链接:
学了c++感觉有了用武之地用string存储字符串,感觉很方便;
题意:给你m个数字用任意数字组合成n的最小倍数,此题用到大数取余的方法以及同余定理;简单的bfs;
#include#include #include #include #include using namespace std;bool vis[5005];int a[20];int T,n,c,m;struct node{ int step,mod; string str;}p,q;char _char(int ss){ if(ss>=0&&ss<=9) return ss+'0'; if(ss>=10&&ss<=15) return ss-10+'A';}void bfs(){ queue Q; for(int i=0;i =500) continue ; for(int i=0;i ='0'&&str1[0]<='9') a[i]=str1[0]-'0'; else a[i]=str1[0]+10-'A'; } sort(a,a+m); if(n==0) { printf(a[0]==0?"0\n":"give me the bomb please\n");continue; } memset(vis,false,sizeof(vis)); bfs(); }}
转载地址:http://musgi.baihongyu.com/