Problem:N的倍数
Description
给你一个数字N,0<=N<=4999
再给一个数字M,代表接下来会给你M类不同的数字
希望你找出一个N的倍数出来,这个值仅由给定的M类数字构成,不包含其它的数字
希望这个N的倍数的值越小越好,如果无解输出0
Input
On the first line - the number N
On the second line - the number M
On the following M lines - the digits X1,X2…XM.
Output
For each data set, the program should write to standard output on a single line the multiple, if such a multiple exists, and 0 otherwise.
Sample Input
22
3
7
0
1
Sample Output
110
这道题灰常巧妙 ,请大家仔细看题目,它是运用递归进行输出的,这是关键,但还是根据代码理解:
#include<bits/stdc++.h>//可爱的头文件
using namespace std;
long long KOG,M,num[100],father[1000000],use[1000000];//此分别为技术的,上一个节点,使用的节点
bool kog[5001],asd=