fork download
  1. #include <iostream>
  2. #include <boost/multiprecision/cpp_int.hpp>
  3.  
  4. template <typename Z>
  5. struct F2
  6. {
  7. F2(const Z &x, const Z &y) : x(x), y(y){}
  8. Z x, y;
  9. };
  10.  
  11. template <typename Z>
  12. F2<Z> operator+(const F2<Z> &a, const F2<Z> &b)
  13. {
  14. return F2<Z>(a.x + b.x, a.y + b.y);
  15. }
  16.  
  17. template <typename Z>
  18. F2<Z> operator*(const F2<Z> &a, const F2<Z> &b)
  19. {
  20. return F2<Z>(a.x * b.x + 2 * a.y * b.y, a.x * b.y + a.y * b.x);
  21. }
  22.  
  23. template <typename Z>
  24. F2<Z> conj(const F2<Z> &a)
  25. {
  26. return F2<Z>(a.x, -a.y);
  27. }
  28.  
  29. int main()
  30. {
  31. using F = F2<boost::multiprecision::cpp_int>;
  32. const F p(2, 1), q(-4, -3), c(-4, 0);
  33. F g(3, 2);
  34. for (int n = 1; n <= 50; ++n) {
  35. auto s = conj(p) * g + p * conj(g) + c;
  36. auto t = conj(q) * g + q * conj(g);
  37. auto a = s.x; a /= 8;
  38. auto b = t.x; b /= 8;
  39. std::cout << "a=" << a << ", b=" << b << std::endl;
  40. g = g * F(3, 2);
  41. }
  42. }
  43.  
Success #stdin #stdout 0s 15312KB
stdin
Standard input is empty
stdout
a=0, b=0
a=2, b=1
a=14, b=6
a=84, b=35
a=492, b=204
a=2870, b=1189
a=16730, b=6930
a=97512, b=40391
a=568344, b=235416
a=3312554, b=1372105
a=19306982, b=7997214
a=112529340, b=46611179
a=655869060, b=271669860
a=3822685022, b=1583407981
a=22280241074, b=9228778026
a=129858761424, b=53789260175
a=756872327472, b=313506783024
a=4411375203410, b=1827251437969
a=25711378892990, b=10650001844790
a=149856898154532, b=62072759630771
a=873430010034204, b=361786555939836
a=5090723162050694, b=2108646576008245
a=29670908962269962, b=12290092900109634
a=172934730611569080, b=71631910824649559
a=1007937474707144520, b=417501372047787720
a=5874690117631298042, b=2433376321462076761
a=34240203231080643734, b=14182756556724672846
a=199566529268852564364, b=82663163018885960315
a=1163158972382034742452, b=481796221556591089044
a=6779387305023355890350, b=2808114166320660573949
a=39513164857758100599650, b=16366888776367372354650
a=230299601841525247707552, b=95393218491883573553951
a=1342284446191393385645664, b=555992422174934068969056
a=7823407075306835066166434, b=3240561314557720840260385
a=45598158005649617011352942, b=18887375465171390972593254
a=265765540958590867001951220, b=110083691476470624995299139
a=1548995087745895585000354380, b=641614773393652358999201580
a=9028204985516782643000175062, b=3739604948885443528999910341
a=52620234825354800273000695994, b=21796014919919008815000260466
a=306693203966612018995004000904, b=127036484570628609361001652455
a=1787538988974317313697023309432, b=740422892503852647351009654264
a=10418540729879291863187135855690, b=4315500870452487274745056273129
a=60723705390301433865425791824710, b=25152582330211071001119327984510
a=353923691611929311329367615092572, b=146599993110813938731970911633931
a=2062818444281274434110779898730724, b=854447376334672561390706141819076
a=12022986974075717293335311777291774, b=4980084264897221429612265939280525
a=70075103400173029325901090765019922, b=29026058213048656016282889493864074
a=408427633426962458662071232812827760, b=169176265013394714668085071023903919
a=2380490697161601722646526306111946640, b=986031531867319631992227536649559440
a=13874516549542647877217086603858852082, b=5747012926190523077285280148873452721