Hello rahn2020 Logout (/logou (/users/rahn2020) PRACTICE (/PROBLEMS/SCHOOL) COMMUNITY (/COMMUNITY) COMPETE (/CONTESTS) HELP (/HELP) DISCUSS (HTTP://DISCUSS.CODECHEF.COM/) ABOUT (/ABOUTUS) Home (/) » Compete (/contests/) » Algomaniac Prelims (/AGPR2020?order=desc&sortBy=successful_submissions) » Pair It Pair It Problem Code: ALPR2002 Submit (/AGPR2020/submit/ALPR2002) You are given a set X containing N unique integers, x1 , x2 , . . . , x, nand a set Y containing N unique integers, y1 , y2 , … , y. nSet S is formed by pairing each element My Submissions All Submissions (/AGPR2020/status/ALPR2002,rahn2020) (/AGPR2020/status/A of set X with an element of set Y, which has not been paired already, to form the set of points (xi, yj ). Find the number of ways of forming set S so that all the points in Successful Submissions the set lie on a straight line in a Cartesian plane. Input: First line will contain T, number of testcases. Then the testcases follow. First line of each testcase contains an integer N. The next line contains N space-separated integers x1 , x2 , . . . , x. n The last line contains N space-separated integers y1 , y2 , … , y. n Output: For each test case, print a single line containing one integer ― the number of possible combinations. Constraints 1 ≤ T ≤ 100 5 2 ≤ N ≤ 2 ∗ 10 9 −10 9 −10 9 ≤ xi ≤ 10 9 ≤ yi ≤ 10 Elements of set X and Y are unique. Sample Input: 1 3 1 2 3 1 2 3 Sample Output: 2 EXPLANATION: This number of ways of forming set S are: [(1, 1), (2, 2), (3, 3)], [(1, 1), (2, 3), (3, 2)], . Number of set S forming a straight [(1, 2), (2, 3), (3, 1)], [(1, 2), (2, 1), (3, 3)], [(1, 3), (2, 2), (3, 1)], [(1, 3), (2, 1), (3, 2)] line is 2. Author: ★ mazumder7 (/users/mazumder7) 4 We use cookies toAdded: improve 6-03-2020 your experience and for analytical purposes. Read our Privacy Policy (/privacy-policy) and Terms (/terms) Date to know more. You consent to our cookies if you continue to use our website. Okay Time Limit: 1.5 secs Source Limit: 50000 Bytes Languages: C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CPP17, PYP3 Submit (/AGPR2020/submit/ALPR2002) Comments CodeChef is a non-commercial competitive programming community About CodeChef (/aboutus/) CEO's Corner (/ceoscorner/) Contact Us (/contactus) CodeChef uses SPOJ © by Sphere Research Labs (http://www.sphere-research.com) In order to report copyright violations of any kind, send in an email to copyright@codechef.com (mailto:copyright@codechef.com) The time now is: 07:38:40 PM Your IP: 223.223.145.157 CodeChef (/) - A Platform for Aspiring Programmers CodeChef was created as a platform to help programmers make it big in the world of algorithms, computer programming, and programming contests. At CodeChef we work hard to revive the geek in you by hosting a programming contest at the start of the month and two smaller programming challenges at the middle and end of the month. We also aim to have training sessions and discussions related to algorithms, binary search, technicalities like array size and the likes. Apart from providing a platform for programming competitions, CodeChef also has various algorithm tutorials and forum discussions to help those who are new to the world of computer programming. Practice Section (/problems/easy) - A Place to hone your 'Computer Programming Skills' Try your hand at one of our many practice problems and submit your solution in the language of your choice. Our programming contest judge accepts solutions in over 55+ programming languages. Preparing for coding contests were never this much fun! Receive points, and move up through the CodeChef ranks. Use our practice section to better prepare yourself for the multiple programming challenges that take place through-out the month on CodeChef. Compete (/problems/easy) - Monthly Programming Contests, Cook-off and Lunchtime Here is where you can show off your computer programming skills. Take part in our 10 days long monthly coding contest and the shorter format Cook-off and Lunchtime coding contests. Put yourself up for recognition and win great prizes. Our programming contests have prizes worth up to INR 20,000 (for Indian Community), $700 (for Global Community) and lots more CodeChef goodies up for grabs. Programming Tools Practice Problems Initiatives Online IDE (/ide) Easy (/problems/easy) Go for Gold (/goforgold) Upcoming Coding Contests (/contests#FutureContests) Medium (/problems/medium) CodeChef for Schools (/school) Contest Hosting (/hostyourcontest) Hard (/problems/Hard) Campus Chapters (/campus_chapter/about) Problem Setting (/problemsetting) Challenge (/problems/challenge) CodeChef for Business (/corporates) CodeChef Tutorials (/wiki/tutorials) Peer (/problems/extcontest) CodeChef Wiki (/wiki) School (/problems/school) FAQ's (/wiki/faq) Policy Terms of Service (/terms) Privacy Policy (/privacy-policy) Refund Policy (/refund-policy) Code of Conduct (/codeofconduct) Bug Bounty Program (/bug-bounty-program) We use cookies to improve your experience and for analytical purposes. Read our Privacy Policy (/privacy-policy) and Terms (/terms) to know more. You consent to our cookies if you continue to use our website. Okay