আলোচনাঃ
Lightoj 1433 Minimum Arc Distance এই problem এ আমাকে O,A,B এর স্থানাংক ( Ox, Oy, Ax, Ay, Bx, By ) দেয়া থাকবে। আমাকে বৃত্তচাপের দৈর্ঘ্য = ACB বের করতে হবে।
উত্তরঃ
এখানে, OA=OB=r. তাহলে r=sqrt(pow(ox-ax),2)+pow(oy-ay),2).
তাহলে r পেয়ে গেছি। এখন দরকার theta.
আমরা জানি, ত্রিভুজের তিন বাহু দেয়া থাকলে তার কোণ বের করার সূত্র হচ্ছে,
cos(A)= (c^2+b^2-a^2)/(2bc) [ কোণ এর বিপরীত দিকের বাহু টা minus হবে। এখানে A এর বিপরীত বাহু = a ]
You can check this site.
আমদের problem এ সুত্রের c=b=r.আর a=o. তাহলে দাঁড়াচ্ছে,
cos(O)= (r^2+r^2-o^2)/(2*r*r)—(2) [ কোণ এর বিপরীত দিকের বাহু টা minus হবে। এখানে O এর বিপরীত বাহু = o ]
তাহলে আমদের o বাহুটাও বের করতে হবে। প্রশ্ন থেকে দেখতে পাচ্ছি, o=AB. তাহলে AB এর দৈর্ঘ্য বের করলেই o বাহু পেয়ে যাবো।
এবার, (2) থেকে theta বের করে (1) no formula তে মান বসালেই উত্তর পাবো।
এখন শুরুতেই যদি আমাদের মাথায় না আসে যে, এই problem এর ক্ষেত্রে OA আর OB same তাহলে
আমরা যদি OA আর OB আবার বের করে cos(A)= (c^2+b^2-a^2)/(2bc)
এই formula তে বসাই তাহলেও answer হবে। যার যেটা আগে মাথায় আসে।
আমি নিচে দুটো code ই দিয়ে দিবো। দেখে নিতে পারেন।
C++ Code:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e6+10;
#define pii pair<int,int>
#define MOD 10000007
#define PI acos(-1.0)
int main()
{
int t,ox,oy,ax,ay,bx,by,cs=1;
scanf("%d",&t);
while(t--)
{
scanf("%d %d %d %d %d %d",&ox,&oy,&ax,&ay,&bx,&by);
double r=sqrt(pow((ox-ax),2)+pow((oy-ay),2));
double o=sqrt(pow((ax-bx),2)+pow((ay-by),2));
double theta=acos((r*r+r*r-o*o)/(2.0*r*r));
double s=r*theta;
printf("Case %d: %.10f\n",cs++,s);
}
}
--------------------------------OR--------------------------------
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e6+10;
#define pii pair<int,int>
#define MOD 10000007
#define PI acos(-1.0)
int dp[N];
int main()
{
int t,ox,oy,ax,ay,bx,by,cs=1;
scanf("%d",&t);
while(t--)
{
scanf("%d %d %d %d %d %d",&ox,&oy,&ax,&ay,&bx,&by);
double r=sqrt(pow((ox-ax),2)+pow((oy-ay),2));
double a=sqrt(pow((ox-bx),2)+pow((oy-by),2));
double b=sqrt(pow((ox-ax),2)+pow((oy-ay),2));
double o=sqrt(pow((ax-bx),2)+pow((ay-by),2));
double theta=acos((a*a+b*b-o*o)/(2.0*a*b));
double s=r*theta;
printf("Case %d: %.10f\n",cs++,s);
}
}
Related Problem : LightOJ – 1331 – Agent J
I’d come to give the go-ahead with you here. Which is not something I typically do! I love reading a post that will make people think. Also, thanks for allowing me to comment!
Thank you for your comment.
One of my favourite sites now, bookmarked for future use
Thanks. Hope new articles will come soon. Be with us. Thanks for your comment.
Ive been exploring on the net hoping to get some ideas on the way to get my personal weblog coded, your present style together with style are wonderful. Did you code it by yourself or did you recruit a coder to do it on your behalf?
It’s a WordPress website. I made it by myself:).
And Congrats for your upcoming website. Hope this will help other people.
Zycie mozna zrozumiec, patrzac nań tylko wstecz. Zyc jednak trzeba naprzod – Soren Kierkegaard
Hope I will understand your language one day 😀
This specific comment reminds myself in which at this point could some sort of great possiblity to further one’s college education and learning. MY SPOUSE AND I ask yourself if POST may well consider instruction online. Right now there exist a multitude of grant options now which were as soon as thus pretty imprecise to find a very few in years past.
Thanks.
Pretty! This was a really wonderful post. Thanks for supplying this info.
Welcome.
This kind of comment reminds my family that at this point could possibly any great opportunity to even more one’s collage education and learning. MY SPOUSE AND I wonder if WHEN I may possibly receive classes on the web. Now there are present a variety of fund programs currently which were as soon as and so quite imprecise to discover a very few typical.
Thanks.
Just to let you know, this content looks a little bit strange from my smart phone. Who knows maybe it is just my cell phone. Great article by the way.
Maybe for the ads it looks strange in mobile.
Spot on with this write-up, I actually suppose this web site wants much more consideration. I’ll most likely be again to learn rather more, thanks for that info. http://www.piano.m106.com
Thanks for your suggestion.
Hey, I remember, much too long since the last time I was here some. Well okay. I need it something I am working on, lucky it has a similar topic as this post. Glad, happy trails.
whoah this blog is great i love reading your articles.
Stay up the great work! You understand, many persons are hunting around for
this info, you could aid them greatly.
Thanks.
Write more, thats all I have to say. Literally,
it seems as though you relied on the video to
make your point. You clearly know what youre
talking about, why throw away your intelligence on just posting videos to
your blog when you could be giving us something informative to read?
How is it that just anyone can create a blog and get as popular as this? Its not like youve said something incredibly impressive more like youve painted a quite picture around an issue that you know nothing about! I dont want to sound mean, right here. But do you actually think that you can get away with adding some pretty pictures and not really say anything?
Read carefully.
I take pleasure in, lead to I discovered exactly what I was having a look for.
You have ended my 4 day long hunt! God Bless you man. Have a nice day.
Bye
Brutal Stuff, still I would have to declare that given the abundance of views this has had it may be desirability meditating about trying to improve the spelling and the english! Made a terribly good read though, great stuff.
Thanks for taking the time to discuss this, I really feel strongly about it and adore understanding much more on this subject. If achievable, as you gain experience, would you thoughts updating your weblog with much more details? It is extremely helpful for me.