Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- int main() {
- std::ifstream fin("input.txt");
- std::ofstream fout("output.txt");
- int n, k;
- fin >> n >> k;
- int num = 0;
- for (int i = 1; i < 10; i++) {
- num++;
- if (i == k) {
- fout << num;
- return 0;
- }
- std::cout << i << ' ';
- for (int j = i * 10; j < i * 10 + 10 && j <= n; j++) {
- num++;
- std::cout << j << ' ';
- if (j == k) {
- fout << num;
- return 0;
- }
- for (int q = j * 10; q < j * 10 + 10 && q <= n; q++) {
- num++;
- std::cout << q << ' ';
- if (q == k) {
- fout << num;
- return 0;
- }
- for (int d = q * 10; d < q * 10 + 10 && d <= n; d++) {
- num++;
- std::cout << d << ' ';
- if (d == k) {
- fout << num;
- return 0;
- }
- for (int t = d * 10; t < d * 10 + 10 && t <= n; t++) {
- num++;
- std::cout << d << ' ';
- if (t == k) {
- fout << num;
- return 0;
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment