Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* [A][M][C][B][N] / [K][R][I][P][6][8] */
- #include <bits/stdc++.h>
- #include <unordered_map>
- using namespace std;
- typedef long long ll;
- const char sp = ' ', nl = '\n';
- const int MOD = 9973;
- ifstream fin("produscartezian2.in");
- ofstream fout("produscartezian2.out");
- int n;
- vector<int> v, curr;
- void back(int idx) {
- if (idx == v.size()) {
- for (int& e : curr)
- fout << e << sp;
- fout << nl;
- }
- else {
- for (int i = 1; i <= v[idx]; ++i) {
- curr[idx] = i;
- back(idx + 1);
- }
- }
- }
- int main() {
- ios::sync_with_stdio(0);
- cin.tie(0), cout.tie(0);
- fin >> n;
- v.resize(n);
- curr.resize(n);
- for (int i = 0; i < n; ++i)
- fin >> v[i];
- back(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment