report VI VI EN
Register | Login
  • HOME
  • PROBLEMSET
  • ROADMAP
  • COMPETITION
  • TOPIC
  • RANKING
  • GUIDE
  • MASHUP
  • ABOUT
  • CONTACT
  • Problem
  • Submit
  • Results
Triangles counting - MarisaOJ: Marisa Online Judge

Triangles counting

Time limit: 1000 ms
Memory limit: 256 MB
Given a coordinate grid of size $n \times m$, count the number of triplets of points on the grid such that the three points form a triangle. In other words, count the number of sets of points $A(x_A, y_A), B(x_B,y_B), C(x_C,y_C)$ where $1 \le x_i \le n$ and $1 \le y_i \le m$, and the three points form a triangle. ### Input - A single line containing two integers $n, m$. ### Output - Print the number of triplets of points. ### Constraints - $1 \le n,m \le 1000$. ### Sample test Input ``` 2 3 ``` Output: ``` 18 ```
Introduction to combinatorics
Binomial coefficient
Fork and knife
Binomial coefficient 2
Equation
Array rearrangement
Value of subsequences
Inequation
Growing mushrooms
Binary matrix
Broken board
Triangles counting
Minecraft graph
Restricted path
Heavenly Peach Garden
Topic
Math
Combinatorics
Rating 1800
Solution (1) Solution