Lightoj 1433 Minimum Arc Distance

Problem link

আলোচনাঃ

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.

LightOj  1433 formula image
circle

আমরা জানি, ত্রিভুজের তিন বাহু দেয়া থাকলে তার কোণ বের করার সূত্র হচ্ছে,

cos(A)= (c^2+b^2-a^2)/(2bc)  [ কোণ এর বিপরীত দিকের বাহু টা minus হবে। এখানে A এর বিপরীত বাহু = a ]

You can check this site.

LightOj  1433 circle question image
Lightoj 1433 Minimum Arc Distance

আমদের 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

This Post Has 27 Comments

  1. Pianino Opis

    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!

    1. tusher

      Thank you for your comment.

    1. tusher

      Thanks. Hope new articles will come soon. Be with us. Thanks for your comment.

  2. Japan Anthem

    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?

    1. tusher

      It’s a WordPress website. I made it by myself:).
      And Congrats for your upcoming website. Hope this will help other people.

  3. Norwegia XMC

    Zycie mozna zrozumiec, patrzac nań tylko wstecz. Zyc jednak trzeba naprzod – Soren Kierkegaard

    1. tusher

      Hope I will understand your language one day 😀

  4. 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.

    1. tusher

      Thanks.

    1. tusher

      Welcome.

  5. 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.

    1. tusher

      Thanks.

  6. Cukrzyca

    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.

    1. tusher

      Maybe for the ads it looks strange in mobile.

  7. Finanse

    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

    1. tusher

      Thanks for your suggestion.

  8. Podatki

    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.

  9. Ralph

    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.

    1. tusher

      Thanks.

  10. Corrine

    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?

  11. WWW.EKONOM.XMC.PL

    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?

    1. tusher

      Read carefully.

  12. Wilfred

    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

  13. Loan Blog

    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.

  14. 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.

Leave a Reply