// Problem: Defender of Childhood Dreams // Contest: Luogu // URL: https://www.luogu.com.cn/problem/CF1583F // Memory Limit: 500 MB // Time Limit: 3000 ms // Auther : MaxDYF // // Powered by CP Editor (https://cpeditor.org)
//#pragma GCC optimize(2) #include<bits/stdc++.h> usingnamespace std; constint N = 2e5 + 10; constint inf = 1 << 30; constlonglong llinf = 1ll << 60; constdouble PI = acos(-1); typedef pair<int, int> pii; typedeflonglong ll; int n, m, k, q;
voidwork() { cin >> n >> k; cout << (int)(ceil(log(n) / log(k))) << endl; for (int i = 0; i < n; i++) for (int j = i + 1; j < n; j++) { int x = i, y = j; int col = 0; while (x != y) { x /= k; y /= k; col++; } cout << col << ' '; } cout << endl; } intmain() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); work(); }