Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //МУЗЕЙ
- #include <iostream>
- #include <string>
- #include <vector>
- #include <fstream>
- using namespace std;
- int main()
- {
- string temp;
- vector <int> time;
- ifstream in("INPUT.txt");
- getline(in, temp);
- int n = stoi(temp);
- while (getline(in, temp))
- {
- time.push_back((temp[0] - '0') * 1000 + (temp[1] - '0') * 100 + (temp[3] - '0') * 10 + (temp[4] - '0'));
- time.push_back((temp[6] - '0') * 1000 + (temp[7] - '0') * 100 + (temp[9] - '0') * 10 + (temp[10] - '0'));
- }
- in.close();
- int k = 0, kmax = 0;
- for (int i = 1; i < 2 * n; i += 2)
- {
- for (int j = i + 1; j < 2 * n; j += 2)
- if (time[i] > time[j])
- k++;
- if (k > kmax)
- kmax = k;
- k = 0;
- }
- ofstream out("OUTPUT.txt");
- out << kmax + 1;
- out.close();
- return 0;
- }
- //ЗМЕЙКА
- #include <iostream>
- #include <string>
- #include <fstream>
- using namespace std;
- int main()
- {
- string temp;
- ifstream in("INPUT.txt");
- getline(in, temp);
- in.close();
- int n = stoi(temp), c = 1, i = 0, j = 0;
- int** arr = new int* [n];
- for (int i = 0; i < n; i++)
- arr[i] = new int[n];
- arr[0][0] = c; c++;
- bool left = true, up = true;
- while (c != n * n)
- {
- if (up)
- {
- if (left)i++;
- else j++;
- arr[i][j] = c; c++;
- while (left ? i != 0 : j != n - 1)
- {
- i--; j++;
- arr[i][j] = c; c++;
- }
- up = !up;
- }
- else
- {
- if (left)j++;
- else i++;
- arr[i][j] = c; c++;
- while (left ? j != 0 : i != n - 1)
- {
- i++; j--;
- arr[i][j] = c; c++;
- }
- up = !up;
- }
- if (i == 0 && j == n - 1 || i == n - 1 && j == 0) left = false;
- }
- arr[n - 1][n - 1] = c;
- ofstream out("OUTPUT.txt");
- for (i = 0; i < n; i++)
- {
- for (j = 0; j < n; j++)
- {
- out << arr[i][j] << " ";
- }
- out << endl;
- }
- out.close();
- for (int i = 0; i < n; i++)
- delete[] arr[i];
- delete[]arr;
- return 0;
- }
- //РАСПАКОВКА СТРОКИ
- #include <iostream>
- #include <string>
- #include <fstream>
- using namespace std;
- int main()
- {
- string str;
- ifstream in("INPUT.txt");
- ofstream out("OUTPUT.txt");
- getline(in, str);
- in.close();
- for (int i = 0, ti = 0, num = 0, discharge = 1, k = 0; i < str.length(); i++)
- {
- if (str[i] >= 'A' && str[i] <= 'Z')
- {
- ti = i - 1;
- while (ti >= 0 && (str[ti] < 'A' || str[ti] > 'Z'))
- {
- num += (str[ti] - '0') * discharge;
- discharge *= 10;
- ti--;
- }
- discharge = 1;
- if (num == 0) num++;
- for (int j = 0; j < num; j++)
- {
- if (k % 40 == 0 && k != 0) out << endl;
- out << str[i];
- k++;
- }
- num = 0;
- }
- }
- out.close();
- return 0;
- }
- //ПРЕДСТАВЛЕНИЕ ЧИСЕЛ
- #include <iostream>
- #include <string>
- #include <fstream>
- using namespace std;
- int nod(int m, int n)
- {
- if (m > n)
- m = m - n;
- else
- n = n - m;
- if (m == n) return m;
- else nod(m, n);
- }
- void rec(int x, int y)
- {
- static int maxnod = 1, mx = x, my = y;
- ofstream out("OUTPUT.txt");
- if ((x + y) % 2 == 0)
- {
- out << (x + y) / 2 << " " << (x + y) / 2;
- out.close();
- return;
- }
- int curnod = nod(x, y);
- if (curnod > maxnod)
- {
- maxnod = curnod;
- mx = x;
- my = y;
- }
- x--; y++;
- if (x == 0)
- {
- out << mx << " " << my;
- out.close();
- return;
- }
- else rec(x, y);
- }
- int main()
- {
- int num;
- ifstream in("INPUT.txt");
- in >> num;
- in.close();
- rec(num - 1, 1);
- return 0;
- }
- //ПОДАРКИ ДЕДА МОРОЗА
- #include <iostream>
- #include <fstream>
- using namespace std;
- void recz(int x, int y, int z, int w, int curw, int& k)
- {
- if (curw == w)
- {
- k++;
- return;
- }
- else if (curw > w) return;
- recz(x, y, z, w, curw + z, k);
- }
- void recy(int x, int y, int z, int w, int curw, int& k)
- {
- if (curw == w)
- {
- k++;
- return;
- }
- else if (curw > w) return;
- recy(x, y, z, w, curw + y, k);
- recz(x, y, z, w, curw + z, k);
- }
- void recx(int x, int y, int z, int w,int curw , int &k)
- {
- if (curw == w)
- {
- k++;
- return;
- }
- else if (curw > w) return;
- recx(x, y, z, w, curw+x, k);
- recy(x, y, z, w, curw+y, k);
- recz(x, y, z, w, curw+z, k);
- }
- int main()
- {
- int k = 0,x,y,z,w;
- ifstream in("INPUT.txt");
- ofstream out("OUTPUT.txt");
- in >> x;
- in >> y;
- in >> z;
- in >> w;
- in.close();
- recx(x, y, z, w, 0, k);
- out << k;
- out.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment