#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double dou;
#define pii pair<int, int>
#define fi first
#define se second
#define pb push_back
#define BITJ(x, j) (((x)>>(j))&1)
#define MASK(j) (1LL<<(j))
#define ALL(v) v.begin(), v.end()
template<typename T> bool maximize(T &x, const T &y) {
if (x < y) {x = y; return 1;}
return 0;
}
template<typename T> bool minimize(T &x, const T &y) {
if (x > y) {x = y; return 1;}
return 0;
}
void output_ans(vector<vector<int>> &ans) {
cout << (int)ans.size() << "\n";
for (vector<int> &cur : ans) {
for (int x : cur) {
cout << x << ' ';
}
cout << "\n";
}
}
const int maxn = 1e6+5;
int n, k;
ll a[maxn];
vector<vector<int>> ans;
namespace sub4{
int cnt;
int gcd(int a, int b){
if (b == 0) return a;
++cnt;
return gcd(b, a%b);
}
void solve() {
cnt = 0;
int val = gcd(n, k);
if (a[1] % cnt != 0) {
cout << -1;
return;
}
val = a[1]/cnt;
int st = 0;
while (st != n) {
int valleft = k;
ans.pb(vector<int>(1, val));
while (valleft > 0) {
st = st%n+1;
ans.back().pb(st);
--valleft;
}
}
output_ans(ans);
}
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
// #define name "task"
// if (fopen(name".inp", "r")) {
// freopen(name".inp", "r", stdin);
// freopen(name".out", "w", stdout);
// }
cin >> n >> k;
for (int i = 1; i <= n; ++i) {
cin >> a[i];
}
return sub4::solve(), 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |