Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #define N 60
- #define M 158
- inline int gcd(int a, int b) {
- while(a&&b) {
- if (a>b) a%=b;
- else b%=a;
- }
- return a+b;
- }
- int r[M] = {6, 10, 12, 14, 15, 18, 20, 21, 22, 24, 26, 28, 30, 33, 34, 35, 36, 38, 39, 40, 42, 44, 45, 46, 48, 50, 51, 52, 54, 55, 56, 57, 58, 60, 62, 63, 65, 66, 68, 69, 70, 72, 74, 75, 76, 77, 78, 80, 82, 84, 85, 86, 87, 88, 90, 91, 92, 93, 94, 95, 96, 98, 99, 100, 102, 104, 105, 106, 108, 110, 111, 112, 114, 115, 116, 117, 118, 119, 120, 122, 123, 124, 126, 129, 130, 132, 133, 134, 135, 136, 138, 140, 141, 142, 143, 144, 145, 146, 147, 148, 150, 152, 153, 154, 155, 156, 158, 159, 160, 161, 162, 164, 165, 166, 168, 170, 171, 172, 174, 175, 176, 177, 178, 180, 182, 183, 184, 185, 186, 187, 188, 189, 190, 192, 194, 195, 196, 198, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 212, 213, 214, 215, 216, 217, 218, 219, 220};
- int g[M][M];
- int n=3,p=0;
- int st[N];
- int tg = 0;
- void rec(int l) {
- int i,j,k,otg=tg;
- if (p==n) {
- if (tg>1) return;
- printf("%d:",n);
- for (i=0;i<n;i++) printf(" %d%c",r[st[i]],",\n"[i==n-1]);
- n++;
- }
- for (i=n-p-1;i<l;i++) {
- for (j=0;j<p;j++) if (g[st[j]][i]<2) break;
- if (j>=p) {
- st[p++]=i;
- if (otg) tg = gcd(otg,r[i]);
- else tg = r[i];
- rec(i);
- p--;
- }
- }
- tg = otg;
- }
- int main () {
- int i,j;
- for (i=0;i<M;i++)
- for (j=0;j<M;j++)
- g[i][j]=gcd(r[i],r[j]);
- rec(M);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement