Skip to content

Commit 730c3a5

Browse files
Merge branch 'opencodeiiita:main' into main
2 parents 853eecf + ff89d41 commit 730c3a5

2 files changed

Lines changed: 133 additions & 0 deletions

File tree

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
## Problem Description
2+
3+
Masha works in an advertising agency. In order to promote a new brand, she wants to conclude contracts with some bloggers.
4+
5+
Masha has connections with `n` different bloggers. Blogger numbered `i` has `ai` followers.
6+
7+
Due to a limited budget, Masha can only sign contracts with `k` different bloggers. She wants the advertisement to be seen by as many people as possible, so she must choose bloggers such that the **total number of followers is maximized**.
8+
9+
Your task is to find the **number of ways** to select `k` bloggers so that the total number of their followers is maximum possible.
10+
11+
Two ways are considered different if there is at least one blogger selected in one way but not in the other.
12+
13+
---
14+
15+
## Input Format
16+
17+
- The first line contains an integer `t` — the number of test cases.
18+
- For each test case:
19+
- The first line contains two integers `n` and `k`
20+
- The second line contains `n` integers `a1, a2, ..., an`, where `ai` is the number of followers of the `i`-th blogger
21+
22+
---
23+
24+
## Output Format
25+
26+
- For each test case, print a single integer — the number of ways to select `k` bloggers such that the total number of followers is maximum possible.
27+
- Since the answer can be large, print it modulo `10^9 + 7`.
28+
29+
---
30+
31+
32+
33+
## Constraints
34+
35+
- `1 ≤ t ≤ 1000`
36+
- `1 ≤ k ≤ n ≤ 1000`
37+
- `1 ≤ ai ≤ n`
38+
- The sum of `n` over all test cases does not exceed `1000`
39+
40+
---
41+
42+
## Sample Input
43+
44+
```
45+
3
46+
4 3
47+
1 3 1 2
48+
4 2
49+
1 1 1 1
50+
2 1
51+
1 2
52+
```
53+
---
54+
55+
## Output
56+
57+
```
58+
2
59+
6
60+
1
61+
```
62+
63+
---
64+
65+
### Additional Resource
66+
67+
For understanding **modular arithmetic and modular inverses**, which are useful for solving problems with answers modulo `10^9+7`, you can check this video:
68+
https://youtu.be/RCq5TYMZEwg
69+
70+
---
71+
72+
73+
[PROBLEM LINK](http://codeforces.com/contest/1475/problem/E)
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
## Problem Description
2+
3+
You are given a single integer `N`.
4+
5+
You are asked to compute the following summation:
6+
7+
Σ(i=1 to N) Σ(j=1 to N) Σ(k=1 to i) Σ(l=1 to j) (gcd(k, i) × gcd(l, j) × gcd(i, j))
8+
9+
Output the value of this summation **modulo 1000000007**.
10+
11+
---
12+
13+
## Input Format
14+
15+
- The input consists of a single integer `N`.
16+
17+
---
18+
19+
## Output Format
20+
21+
- Output the value of the summation modulo `1000000007`.
22+
23+
---
24+
25+
## Constraints
26+
27+
- 1 ≤ N ≤ 10^6
28+
29+
---
30+
31+
32+
## Sample Input 1
33+
34+
```
35+
2
36+
```
37+
---
38+
39+
## Output
40+
41+
```
42+
25
43+
```
44+
---
45+
46+
## Sample Input 2
47+
48+
```
49+
8
50+
```
51+
---
52+
53+
## Output
54+
55+
```
56+
13348
57+
```
58+
---
59+
60+
[PROBLEM LINK](https://www.codechef.com/problems/YETGCD?tab=statement)

0 commit comments

Comments
 (0)