ACM (UVa): 10050


Data type:
Integer

Explanation:
Declare an integer array of 3651 elements.
Every 6th and 7th elements should be filled up with 1. // thus all holidays will be inserted 1.

Now at every value of ‘p’ insert the pth elements with -1 (if it hasn’t inserted already by 1)

At last, count the elements contained -1.

Critical input:
3
3650
5
19
21
17
109
121
2000
4
11
12
13
2
10
3
3
4
5
Critical output:
326
830
6

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s