Advertisement
Georgiy031

Untitled

Oct 16th, 2020
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.15 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4. typedef long long ll;
  5. typedef unsigned long long ull;
  6. #define all(x) x.begin(), x.end()
  7. #define rall(x) x.rbegin(), x.rend()
  8. #define endl '\n'
  9. #define boostIO() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  10. ll gcd(ll a, ll b) { return (b == 0 ? a : gcd(b, a % b)); }
  11.  
  12. struct pt {
  13.     double x, y;
  14. };
  15. struct pt3 {
  16.     double x, y, z;
  17. };
  18. double f(double x, double y) {
  19.     return x * x * x - 3 * x * y * y - x * x + y * y + x - 1;
  20. }
  21. double g(double x, double y) {
  22.     return 3 * x * x * y - y * y * y - 2 * x * y + y;
  23. }
  24.  
  25. void initial_points() {
  26.     double Xm = -10, Xp = 10, x;
  27.     double Ym = -10, Yp = 10, y;
  28.  
  29.     float dl = 0.1;
  30.  
  31.     float curmin = 1000000.;
  32.  
  33.     while (curmin > 999999) {
  34.         for (x = Xm; x < Xp; x = x + 0.1)
  35.             for (y = Ym; y < Yp; y = y + 0.1) {
  36.  
  37.                 double fc = f(x, y);
  38.                 double gc = g(x, y);
  39.  
  40.                 if ((fc <= 0) || (gc <= 0)) continue;
  41.  
  42.                 double dv = fabs(fc) + fabs(gc);
  43.  
  44.                 if (dv > curmin) continue;
  45.  
  46.                 double x0 = x;
  47.                 double y0 = y;
  48.  
  49.                 curmin = dv;
  50.  
  51.                 continue;
  52.             }
  53.  
  54.             if (curmin <= 999999.) break;
  55.         dl = dl / 2;
  56.     }
  57.     cout << x << endl << y << endl;
  58. }
  59.  
  60. signed main() {
  61.    
  62. }
  63.  
  64.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement