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