Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Язык PCMS Web Client
- ИнформацияРезультатыОтправитьРешенияВопросыФайлыСоревнованияВыход
- Исходный код
- PCMS.cpp
- ��#define _CRT_SECURE_NO_WARNINGS
- #define FNAME "telemetry"
- #include <iostream>
- #include <fstream>
- #include <algorithm>
- #include <string>
- #include <vector>
- #include <map>
- #include <stack>
- #include <queue>
- using namespace std;
- const int N = 1e5 + 5;
- vector<int> inc(N, 1);
- string a, b;
- long long n, m, k, x, y, z, ans = 0;
- void next(int i = 0) {
- if (a[i] + inc[i] >= k + '0' || a[i] + inc[i] < '0') {
- next(i + 1);
- inc[i] *= -1;
- }
- else {
- a[i] += inc[i];
- }
- }
- int main() {
- #ifdef _DEBUG
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- #else
- freopen(FNAME".in", "r", stdin);
- freopen(FNAME".out", "w", stdout);
- #endif
- ios::sync_with_stdio(false);
- cin >> n >> k;
- a.assign(n, '0');
- b.assign(n, '0' + k - 1);
- while (a != b) {
- cout << a << '\n';
- next();
- }
- if (k % 2 == 0) {
- b.assign(n - 1, '0');
- b.push_back('0' + k - 1);
- while (a != b) {
- cout << a << '\n';
- next();
- }
- }
- cout << a << '\n';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement