Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- int main()
- {
- int n,d,i,j;
- long long int k;
- scanf("%d %I64d %d",&n,&k,&d);
- if(k>=n)
- for(i = 0 ; i<d ; i++)
- {
- for(j = 0 ; j<n ; j++){
- printf("%d",j+1);
- if(j<n-1) printf(" ");
- }
- if(i < d-1) printf("\n");
- }
- else if(n > pow(k,d)) printf("-1");
- else {
- int arr[d][n],s2 = 1, s = s2%k;
- for(i = 0 ; i < d ; i++){
- s2 = 1, s= s2%k;
- for(j = 0 ; j < n ; j++){
- if(j >= n*s2/pow(k,i+1)){
- s2++;
- s = s2%k;
- }
- printf("%d",s+1);
- if(j<n-1) printf(" ");
- }
- if(i < d-1) printf("\n");
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement