HDU 6150 Vertex Cover(构造)

http://acm.hdu.edu.cn/showproblem.php?pid=6150

 1 #include<iostream>
 2 #include<algorithm>
 3 #include<cstring>
 4 #include<cstdio>
 5 #include<vector>
 6 #include<stack>
 7 #include<queue>
 8 #include<cmath>
 9 #include<map>
10 #include<set>
11 using namespace std;
12 typedef long long ll;
13 const int INF = 0x3f3f3f3f;
14 const int maxn=3000+5;
15 
16 const int n=50;
17 struct node
18 {
19     int u,v;
20 }e[maxn];
21 
22 int main()
23 {
24     //freopen("in.txt","r",stdin);
25     int cnt=n;
26     int e_cnt=0;
27     for(int i=1;i<=n;i++)
28     {
29         int num=n/i;
30         int left=1;
31         for(int j=1;j<=num;j++)
32         {
33             for(int k=1;k<=i;k++)
34             {
35                e[e_cnt].u=left;
36                e[e_cnt].v=cnt+j;
37                e_cnt++;
38                left++;
39             }
40         }
41         cnt+=num;
42     }
43     printf("%d %d
",cnt,e_cnt);
44     for(int i=0;i<e_cnt;i++) printf("%d %d
",e[i].u,e[i].v);
45     printf("%d
",n);
46     for(int i=1;i<=n;i++) printf("%d
",i);
47     return 0;
48 }
原文地址:https://www.cnblogs.com/zyb993963526/p/7403215.html