-
Notifications
You must be signed in to change notification settings - Fork 1
/
lexicographicseries.c
84 lines (63 loc) · 983 Bytes
/
lexicographicseries.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include<stdio.h>
int main()
{
int array[1000000],x,i,j,n,k,count;
scanf("%d%d",&n,&k);
for(x=0;x<k;x++)
{
array[x]=1;
//~ printf("%d ",array[x]);
}
count=1;
while(1)
{
i=0;
array[i]++;
while(array[i]==n+1 && i!=k-1)
{
array[i+1]++;
i++;
}
if(array[k-1]==n+1)
break;
j=i;
for(;i>=0;i--)
array[i]=array[j];
for(x=k-1;x>=0;x--)
continue;
//~ printf("%d ",array[x]);
//~ printf("\n");
++count;
//~ printf("count %d\n",++count);
}
printf("%d\n",count);
for(x=0;x<k;x++)
{
array[x]=1;
printf("%d ",array[x]);
}
printf("\n");
//~ count=1;
while(1)
{
i=0;
array[i]++;
while(array[i]==n+1 && i!=k-1)
{
array[i+1]++;
i++;
}
if(array[k-1]==n+1)
break;
j=i;
for(;i>=0;i--)
array[i]=array[j];
for(x=k-1;x>=0;x--)
printf("%d ",array[x]);
printf("\n");
++count;
//~ printf("count %d\n",++count);
}
//~ printf("%d\n",count);
return 0;
}