## BestCoder Round #63(Div.2) (4/4) (Div.1) (3/4)

maksyuki 发表于 比赛 分类，标签:

# A sequence1

Problem Description

Given an array a with length n, could you tell me how many pairs (i,j) ( i < j ) for abs(ai−aj) mod b=c.

Input

For each cases, first come 3 integers, n,b,c(1≤n≤100,0≤c<b≤109)

Then follows n integers ai(0≤ai≤109)

Output

For each cases, please output an integer in a line as the answer.

Sample Input

3 3 2
1 2 3
3 3 1
1 2 3

Sample Output

1

2

Source

BestCoder Round #63 (div.2)

# B sequence2

Problem Description

Given an integer array bi with a length of n, please tell me how many exactly different increasing subsequences. P.S. A subsequence bai(1≤i≤k) is an increasing subsequence of sequence bi(1≤i≤n) if and only if 1≤a1<a2<...<ak≤n and ba1<ba2<...<bak.
Two sequences ai and bi is exactly different if and only if there exist at least one i and ai≠bi.

Input

For each cases, first come 2 integers, n,k(1≤n≤100,1≤k≤n)

Then follows n integers ai(0≤ai≤109)

Output

For each cases, please output an integer in a line as the answer.

Sample Input

3 1
1 2 2
3 2
1 2 3

Sample Output

2

3

Source

BestCoder Round #63 (div.2)

# C matrix

Problem Description

Given a matrix with n rows and m columns ( n+m is an odd number ), at first , you begin with the number at top-left corner (1,1) and you want to go to the number at bottom-right corner (n,m). And you must go right or go down every steps. Let the numbers you go through become an array a1,a2,...,a2k. The cost is a1∗a2+a3∗a4+...+a2k−1∗a2k. What is the minimum of the cost?

Input

For each cases, first come 2 integers, n,m(1≤n≤1000,1≤m≤1000)

N+m is an odd number.

Then follows n lines with m numbers ai,j(1≤ai≤100)

Output

For each cases, please output an integer in a line as the answer.

Sample Input

2 3
1 2 3
2 2 1
2 3
2 2 1
1 2 4

Sample Output

4

8

Source

BestCoder Round #63 (div.2)

# D balls

Problem Description

There are n balls with m colors. The possibility of that the color of the i-th ball is color j is ai,jai,1+ai,2+...+ai,m. If the number of balls with the j-th is x, then you should pay x2 as the cost. Please calculate the expectation of the cost.

Input

For each cases, first come 2 integers, n,m(1≤n≤1000,1≤m≤1000)

Then follows n lines with m numbers ai,j(1≤ai≤100)

Output

Sample Input

2 2
1 1
3 5

2 2
4 5
4 2

2 2
2 4
1 4

Sample Output

3.00

2.96

3.20

Source

BestCoder Round #63 (div.2)