Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <vector>
- #include <queue>
- #include <algorithm>
- #include <string>
- #include <stack>
- #include <set>
- #include <map>
- #define pii pair <int, int>
- #define pb(x) push_back(x)
- using namespace std;
- using ll = long long;
- using ld = long double;
- using db = double;
- void cv(vector <int> &v) {
- for (auto x : v) cout << x << ' ';
- cout << "\n";
- }
- void cvl(vector <ll> &v) {
- for (auto x : v) cout << x << ' ';
- cout << "\n";
- }
- void cvv(vector <vector <int> > &v) {
- for (auto x : v) cv(x);
- cout << "\n";
- }
- void cvb(vector <bool> v) {
- for (bool x : v) cout << x << ' ';
- cout << "\n";
- }
- void cvs(vector <string> v) {
- for (auto a : v) {
- cout << a << "\n";
- }
- }
- void cvp(vector <pii> a) {
- for (auto p : a) {
- cout << p.first << ' ' << p.second << "\n";
- }
- cout << "\n";
- }
- vector <int> h = {9, 1, 30, 4, 24, 12, 8, 23, 18, 7, 16, 15, 21, 26, 10, 17, 19, 22, 13, 28, 14, 11, 2, 29, 3, 6, 27, 0, 5, 25, 31, 20};
- bool sh = 0;
- int k;
- pii g(pii cd,int cnt) {
- int c = cd.first, d = cd.second;
- if (sh) {
- cout << "cd\n";
- cout << c << ' ' << d << "\n";
- cout << "cnt = " << cnt << "\n";
- }
- if (cnt == 128) {
- return cd;
- }
- if (sh) {
- //cout << "";
- }
- pii p = {d, (c + h[ (d + k) % 32 ]) % 32 };
- return g(p, cnt + 1);
- }
- int main() {
- ios::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- vector <pii> fr = {
- {
- 23, 0
- },
- {
- 10, 4
- },
- {
- 0, 6
- },
- {
- 1, 29
- }
- },
- to = {
- {
- 25, 9
- },
- {
- 7, 13
- },
- {
- 9, 7
- },
- {
- 14, 14
- }
- };
- for (int i = 0; i <= 31; ++i) {
- k = i;
- bool ok = 1;
- for (int j = 0; j < 4; ++j) {
- pii res = g(fr[j], 0);
- if (sh) {
- cout << "k = " << k << "\n";
- cout << "res\n";
- cout << res.first << ' ' << res.second << "\n";
- }
- if (res != to[j]) {
- ok = 0;
- }
- }
- if (ok) {
- cout << "k = " << k << "\n";
- cout << "OK\n";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement