Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<vector>
- #include <string>
- #include<algorithm>
- #include <iostream>
- #include <queue>
- #include<set>
- #include<cmath>
- #include<math.h>
- using namespace std;
- #define ll double
- #define pll pair<long long, long long>
- #define mp make_pair
- #define pb push_back
- #define all(a) a.begin(), a.end()
- #define rall(a) a.rbegin(), a.rend()
- #define cin(a) for(ll ghgh = 0; ghgh<a.size(); ghgh++) cin>>a[ghgh];
- #define pcin(a) for(ll ghgh = 0; ghgh<a.size(); ghgh++) cin>>a[ghgh].first>>a[ghgh].second;
- #define cout(a) for(ll ghgha = 0; ghgha<a.size(); ghgha++) cout<<a[ghgha]<<endl;
- #define pcout(a) for(ll ghgha = 0; ghgha<a.size(); ghgha++) cout<<a[ghgha].first<<" "<<a[ghgha].second<<endl;
- const ll inf = 1e9 + 7, llinf = 1e18 + 123;
- void xru() {
- setlocale(LC_ALL, "rus");
- /*freopen(".in", "r", stdin);
- freopen(".out", "w", stdout);*/
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- cout.tie(NULL);
- }
- ll abes(ll x) {
- if (x < 0) {
- return x * (ll)-1;
- }
- else {
- return x;
- }
- }
- ll f(ll a, ll b) {
- return (b - a) / b;
- }
- bool fnd(ll x, ll y,ll sx, ll sy, ll cnt, ll as) {
- bool flag = false;
- if ((abes(f(x, y) - (sx * sy)) < 0.001)) {
- cout <<"//"<< cnt<<"//"<<as<<endl;
- return true;
- }
- if (cnt > 15) {
- return false;
- }
- if (fnd(f(x, y), y, sx, sy, cnt + 1, 0)) {
- cout << as << endl;
- flag = true;
- }
- if (fnd(f(y, x), y, sx, sy, cnt + 1, 1)) {
- cout << as << endl;
- flag = true;
- }
- if (fnd(x, f(x, y), sx, sy, cnt + 1, 2)) {
- cout << as << endl;
- flag = true;
- }
- if (fnd(x, f(y, x), sx, sy, cnt + 1, 3)) {
- cout << as << endl;
- flag = true;
- }
- if (flag) return true;
- else return false;
- }
- int main()
- {
- xru();
- ll sx = 139, sy = 167;
- ll x = 139, y = 167;
- ll cnt = 0;
- fnd(sx, sy, sx, sy, cnt, 0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement