Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <set>
- #include <vector>
- #include <iterator>
- using namespace std;
- int k=0,ans=0;
- double s(double x, double y){
- return 0.25*pow(sqrt(pow(x-y,2)+4)-x-y,2);
- }
- struct st{
- double s,x,y;
- int m,n;
- };
- vector<st>mainSet;
- void add(st x){ // binsearch?
- auto i=mainSet.begin(); //decreasing order
- while (i!=mainSet.end()&&i->s>x.s) i++;
- mainSet.insert(i,x);
- }
- double next_x(double x,double y){
- return (x-y+sqrt(pow(y-x,2)+4))/2;
- }
- double next_y(double x,double y){
- return 2/(x-y+sqrt(pow(y-x,2)+4));
- }
- st next_sq1(st x){
- return {s(x.x,next_y(x.x,x.y)),x.x,next_y(x.x,x.y),x.m+1,x.n}; //m -- y, n -- x
- }
- st next_sq2(st x){
- return {s(next_x(x.x,x.y),x.y),next_x(x.x,x.y),x.y,x.m,x.n+1}; //m -- y, n -- x
- }
- int main()
- {
- add({s(1,1),1,0,0,0});
- while (k!=20){
- ans++;
- st temp=*mainSet.begin();
- if (temp.m==3&&temp.n==3) k++;
- mainSet.erase(mainSet.begin());
- add(next_sq1(temp));
- add(next_sq2(temp));
- }
- cout<<ans;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement