Construct the series Codeforces Round #261 (Div. 2) C

Source: Internet
Author: User

Construct the series Codeforces Round #261 (Div. 2) C

C. Pashmak and Busestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

Recently Pashmak has been employed in a transportation company. The company hasKBuses and has a contract with a school which hasNStudents. The school planned to take the studentsDDifferent placesDDays (each day in one place ). each day the company provides all the buses for the trip. pashmak has to arrange the students in the buses. he wants to arrange the students in a way that no two students become close friends. in his ridiculous idea, two students will become close friends if and only if they are in the same buses for allDDays.

Please help Pashmak with his weird idea. Assume that each bus has an unlimited capacity.

Input

The first line of input contains three space-separated integersN,?K,?D(1? ≤?N,?D? ≤? 1000; 1? ≤?K? ≤? 109 ).

Output

If there is no valid arrangement just print-1. Otherwise printDLines, in each of them printNIntegers.J-Th integer ofI-Th line shows which busJ-Th student has to take onI-Th day. You can assume that the buses are numbered from 1K.

Sample test (s) input
3 2 2
Output
1 1 2 1 2 1 
Input
3 2 1
Output
-1
Note

Note that two students become close friends only if they share a bus each day. But the bus they share can differ from day to day.



N students, k cars (unlimited capacity), d days. Each student is required to take the same car every day.

Just do it as a k-in-number, and use it as the k-in-Number of n d-bits. The Code is as follows:

#include
 
  #include
  
   #include
   
    #include
    #include
     
      #include#include
      
       using namespace std;typedef long long LL;int A[1005][1005];int main(){ int n,d,k; while(~scanf("%d%d%d",&n,&k,&d)) { bool f1=false; LL tmp=1; for(int i=1;i<=d;i++) { tmp*=k; if(tmp>=n) { f1=true; break; } } if(!f1){ puts("-1"); continue; } for(int i=0;i
       
        


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.