### gregr's blog

By gregr, history, 6 weeks ago, ,

I am trying to copy a vector<vector<pair<int,int>>> to some another with same structure, can someone provide me with peice of code of how to do it. I do not know why deep copy (in comments does not works) .. suggestions are welcomed.

• -10

By gregr, history, 6 months ago, ,

hello , I solved question 3 in contest which gave me wrong answer inspite of my best attempts. After contest i found out the test case at which my answer went wrong. i ran the same at online ide which is giving correct ans. Any suggestions? **https://codeforces.com/contest/1304/submission/71150303** test case: 2 10 8 -8 7 16 -10 -5

• 0

By gregr, history, 7 months ago, ,

All , I have a question for you . We are given a set of points in 2-D plane . we need to form a square centered at origin such that it has max perimeter and does not encloses any of those points . Can you answer this , or can you atleast refer me resources from where can i study this. your reply is greatly appreciated. kindly do not downvote this post, you can get answer if someone replies.

• +10

By gregr, history, 7 months ago, ,

the problem is : given a,b,x; (obviously integers) find largest integer n such that a*n+b*digits_in(n) <=x; the following is approach adopted by me int num=9; for(int i=1;i<12;++i){ int d=digit(num); int ap=((a*num)+(b*d)); if(ap<=x){ num*=10; num+=9; }else{ d--; int pp=d*b; cout<<pp<<endl; pp=x-pp; cout<<pp<<endl; num=pp/a; break; } } clearly found the number of digits in n precisely: then the factor digits_in(n)*b is constant. subtracting it from x then dividing it by 'a' should give me proper value of n. the above does not works for test case "234 56789 314159265" or do i have to do binary search. looking for suggestions.