0% found this document useful (0 votes)
21 views1 page

Prob-Intricate Polygons

Mr. Don has a bag of sticks of various lengths and wants to know how many different polygons he can make with the sticks. He is given a number of sticks and their lengths as input. The output is the number of different polygons that can be made from the sticks, modulo 10^9 + 7. The task is to help Mr. Don calculate the number of ways to choose sticks from his bag to form different polygons.

Uploaded by

dungakaishi900
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views1 page

Prob-Intricate Polygons

Mr. Don has a bag of sticks of various lengths and wants to know how many different polygons he can make with the sticks. He is given a number of sticks and their lengths as input. The output is the number of different polygons that can be made from the sticks, modulo 10^9 + 7. The task is to help Mr. Don calculate the number of ways to choose sticks from his bag to form different polygons.

Uploaded by

dungakaishi900
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

The 2023 ICPC Vietnam

Southern Provincial Programming Contest


University of Science, VNU-HCM
October 15th, 2023
Problem I
Intricate Polygons
Time Limit: 1 Second
Memory Limit: 512 megabytes
On a beautiful sunny day in Dam Sen Park, Mr. Don holds a bag of sticks
of various lengths. Mr. Don has realized that, with these sticks, some sticks
can be combined to create interesting polygons, while others cannot.
For example, Mr. Don has three sticks in his bag with lengths of 5, 3, and
4, respectively. He knows that with these three sticks, he can arrange them
to form a beautiful triangle. However, the previous day, when Mr. Don had
four sticks in his bag with lengths of 5, 3, 4, and 20, he knew there was no
way to arrange them into a valid quadrilateral.
Here is your task: Help Mr. Don calculate how many different ways to choose sticks from his bag to
create different polygons. Two polygons are considered different if at least one stick is used in one
polygon but not present in the other, and vice versa.

Input
The first line contains an integer 𝑛 (1 ≤ 𝑛 ≤ 5000) – number of sticks in Mr. Don’s bag.
The second line contains 𝑛 integers 𝑙1 , 𝑙2 , . . . , 𝑙𝑛 (1 ≤ 𝑙𝑖 ≤ 5000) , which are the lengths of the
𝑛 corresponding sticks.

Output
The output contains a positive integer, which is the number of different polygons that can be created
modulo 109 + 7.

Sample Input Sample Output Explanation


4 5 There are 4 triangles with
2 2 2 2 sides {2,2,2}
and 1 quadrilateral with
sides {2,2,2,2}
5 9 There are 9 polygons
1 2 3 4 5 {2,3,4}, {2,4,5}, {3,4,5},
{1,2,3,4}, {1,2,3,5},
{1,2,4,5}, {1,3,4,5},
{2,3,4,5}, {1,2,3,4,5}

You might also like