Advertisement
Ginger_samurai

Untitled

May 19th, 2020
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.90 KB | None | 0 0
  1. #include<vector>
  2. #include <string>
  3. #include<algorithm>
  4. #include <iostream>
  5. #include <queue>
  6. #include<set>
  7. #include<cmath>
  8. #include<math.h>
  9. using namespace std;
  10. #define ll double
  11. #define pll pair<long long, long long>
  12. #define mp make_pair
  13. #define pb push_back
  14. #define all(a) a.begin(), a.end()
  15. #define rall(a) a.rbegin(), a.rend()
  16. #define cin(a) for(ll ghgh = 0; ghgh<a.size(); ghgh++) cin>>a[ghgh];
  17. #define pcin(a) for(ll ghgh = 0; ghgh<a.size(); ghgh++) cin>>a[ghgh].first>>a[ghgh].second;
  18. #define cout(a) for(ll ghgha = 0; ghgha<a.size(); ghgha++) cout<<a[ghgha]<<endl;
  19. #define pcout(a) for(ll ghgha = 0; ghgha<a.size(); ghgha++) cout<<a[ghgha].first<<" "<<a[ghgha].second<<endl;
  20. const ll inf = 1e9 + 7, llinf = 1e18 + 123;
  21. void xru() {
  22.  setlocale(LC_ALL, "rus");
  23.  /*freopen(".in", "r", stdin);
  24.  freopen(".out", "w", stdout);*/
  25.  ios_base::sync_with_stdio(false);
  26.  cin.tie(NULL);
  27.  cout.tie(NULL);
  28. }
  29.  
  30. ll abes(ll x) {
  31.     if (x < 0) {
  32.         return x * (ll)-1;
  33.     }
  34.     else {
  35.         return x;
  36.     }
  37. }
  38. ll f(ll a, ll b) {
  39.     return (b - a) / b;
  40. }
  41.  
  42. bool fnd(ll x, ll y,ll sx, ll sy, ll cnt, ll as) {
  43.     bool flag = false;
  44.     if ((abes(f(x, y) - (sx * sy)) < 0.001)) {
  45.         cout <<"//"<< cnt<<"//"<<as<<endl;
  46.         return true;
  47.     }
  48.     if (cnt > 15) {
  49.         return false;
  50.     }
  51.     if (fnd(f(x, y), y, sx, sy, cnt + 1, 0)) {
  52.         cout << as << endl;
  53.         flag = true;
  54.     }
  55.     if (fnd(f(y, x), y, sx, sy, cnt + 1, 1)) {
  56.         cout << as << endl;
  57.         flag = true;
  58.     }
  59.     if (fnd(x, f(x, y), sx, sy, cnt + 1, 2)) {
  60.         cout << as << endl;
  61.         flag = true;
  62.     }
  63.     if (fnd(x, f(y, x), sx, sy, cnt + 1, 3)) {
  64.         cout << as << endl;
  65.         flag = true;
  66.     }
  67.     if (flag) return true;
  68.     else return false;
  69.  
  70. }
  71.  
  72.  
  73.  
  74. int main()
  75. {
  76.  xru();
  77.  ll sx = 139, sy = 167;
  78.  ll x = 139, y = 167;
  79.  ll cnt = 0;
  80.  fnd(sx, sy, sx, sy, cnt, 0);
  81.  
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement