hdu 3335 Divisibility(Dancing Links 重复覆盖)

Divisibility

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1592    Accepted Submission(s): 608


Problem Description
As we know,the fzu AekdyCoin is famous of math,especially in the field of number theory.So,many people call him "the descendant of Chen Jingrun",which brings him a good reputation.
AekdyCoin also plays an important role in the ACM_DIY group,many people always ask him questions about number theory.One day,all members urged him to conduct a lesson in the group.The rookie daizhenyang is extremely weak at math,so he is delighted.
However,when AekdyCoin tells us "As we know, some numbers have interesting property. For example, any even number has the property that could be divided by 2.",daizhenyang got confused,for he don't have the concept of divisibility.He asks other people for help,first,he randomizely writes some positive integer numbers,then you have to pick some numbers from the group,the only constraint is that if you choose number a,you can't choose a number divides a or a number divided by a.(to illustrate the concept of divisibility),and you have to choose as many numbers as you can.
Poor daizhenyang does well in neither math nor programming.The responsibility comes to you!
 

Input
An integer t,indicating the number of testcases,
For every case, first a number n indicating daizhenyang has writen n numbers(n<=1000),then n numbers,all in the range of (1...2^63-1).
 

Output
The most number you can choose.
 

Sample Input
 
   
1 3 1 2 3
 

Sample Output
 
   
2 Hint: If we choose 2 and 3,one is not divisible by the other,which is the most number you can choose.
 


给n个数 取出一些数 使得这些数互相之间不能整除  求出最多的个数

转化为Dancing Links模型  n行n列的01矩阵 

i行j列为1表示 a[i] a[j]互相之间可以整除 求出最多有多少行使得每列至少有一个1

(为何是最多 现在我也没太想明白)

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

#define MEM(a,x) memset(a,x,sizeof a)
#define eps 1e-8
#define MOD 10009
#define INF 99999999
#define ll __int64
#define bug cout<<"here"<ansd) ansd=d;
            return;
        }
        int c=R[0];
        for(int i=R[0];i!=0;i=R[i])
            if(S[i]





你可能感兴趣的:(Dancing,Links)