延庆长沙网站建设,公司网页设计模板,网络服务器是指为网络提供资源并对这些资源进行管理的计算机,Wordpress 页面拼接题目链接 很难想。会哈希#xff0c;但是想不出。需要一个转化#xff0c;本来是求某一段上的二进制上每一位的1数目相等#xff0c;转化为找两段相等的#xff0c;换元可推出公式。最后注意特判。。 1 #include iostream2 #include cstdio3 #include …题目链接 很难想。会哈希但是想不出。需要一个转化本来是求某一段上的二进制上每一位的1数目相等转化为找两段相等的换元可推出公式。最后注意特判。。 1 #include iostream2 #include cstdio3 #include cstring4 #include string5 using namespace std;6 #define MOD 977777 struct node8 {9 int data;
10 struct node *next;
11 }*head[MOD],hash[60000];
12 int sum[100001][31];
13 int c[100001][31];
14 int n,m;
15 int judge(int x,int y)
16 {
17 int i;
18 for(i 0; i m; i )
19 {
20 if(c[x][i] ! c[y][i])
21 return 0;
22 }
23 return 1;
24 }
25 int main()
26 {
27 int i,j,a,key,ans 0,num 0;
28 node *q,*t;
29 scanf(%d %d,n,m);
30 for(i 1; i n; i )
31 {
32 scanf(%d,a);
33 for(j 0; j m; j )
34 {
35 if(a(1j))
36 sum[i][j] sum[i-1][j] 1;
37 else
38 sum[i][j] sum[i-1][j];
39 }
40 }
41 for(i 1; i n; i )
42 {
43 key 0;
44 for(j 1; j m; j )
45 {
46 c[i][j] sum[i][j]-sum[i][0];
47 key c[i][j]*j;
48 }
49 for(j 1;j m;j )
50 {
51 if(c[i][j] ! 0)
52 break;
53 }
54 if(j mans i) ans i;//特判是否全是0
55 key key%MOD;
56 if(key 0)
57 key key MOD;
58 for(t head[key]; t ! NULL; t t-next)
59 {
60 if(ans (i - t-data)judge(i,t-data))
61 {
62 ans i - t-data;
63 }
64 }
65 if(t NULL)
66 {
67 q hash[num];
68 q - data i;
69 q - next head[key];
70 head[key] q;
71 }
72 }
73 printf(%d\n,ans);
74 return 0;
75 } 转载于:https://www.cnblogs.com/naix-x/archive/2013/01/14/2860223.html