Sunday, 5 March 2017

Google Kickstart (previously APAC) 2017 Round A

Problem A
https://codejam.withgoogle.com/codejam/contest/8284486/dashboard#s=p0


Approach : 
Let no, of dots be r rows and c columns. 
For side length=1  => No. of squares = (r-1)*(c-1)
For side length=2  => No. of squares=2*(r-2)*(c-2)
     Because all axis aligned can also be diagonally arranged atmost 1 way
For side length=3  => No. of squares=3*(r-3)*(c-3)
    Because all axis aligned can also be diagonally arranged atmost 2 way
      .
      .
      .
So on till side length=min(r,c)-1

Summing up all : we get 
          
S(n)=((r*(r-1))/2)^2-((r+c)*(r-1)*r*(2r-1))/6+(r*c*(r-1)*r)/2
      
     Modulo can be taken using modular inverse of 2 , 6 .

 
   

3 comments:

  1. With a dedicated focus on cybersecurity, DevStringX has earned a strong reputation as a security testing company in India. Their security testing services in India offer in-depth analysis and expert recommendations to fix vulnerabilities in your software. Their service offerings are tailored to meet the needs of clients from all sectors, making them a top security testing services company.

    ReplyDelete
  2. CloveHR offers a robust employee management system tailored for modern businesses seeking agility and clarity in HR operations. Integrated with a dynamic leave management system, it manages time-off policies, tracks balances, and auto-generates leave reports. CloveHR reduces paperwork, improves communication, and ensures seamless leave and employee data coordination.

    ReplyDelete