Codeforces Round 752 (Div. 1)


A. Di-visible Confusion
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
3
1 2 3
1
2
2
7 7
10
384836991 191890310 576823355 782177068 404011431 818008580 954291757 160449218 155374934 840594328
8
6 69 696 69696 696969 6969696 69696969 696969696
Output
YES
NO
YES
YES
NO
----------------------------------------------------------------------------------------------------
B. Moderate Modular Mode
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
4 8
4 2
420 420
69420 42068
Output
4
10
420
9969128
----------------------------------------------------------------------------------------------------
C. Extreme Extension
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
3
5 4 3
4
3 2 1 4
1
69
8
7264 40515 28226 92776 35285 21709 75124 48163
Output
5
9
0
117
----------------------------------------------------------------------------------------------------
D. Artistic Partition
time limit per test: 3 seconds
memory limit per test: 1024 megabytes
input: standard input
output: standard output

Examples
Input
4
6 2
4 4
3 1
10 3
Output
8
4
6
11
----------------------------------------------------------------------------------------------------
E. A Perfect Problem
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 998244353
Output
4
Input
4 100000007
Output
32
Input
69 999999937
Output
456886663
----------------------------------------------------------------------------------------------------
F. October 18, 2017
time limit per test: 4 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
6
2 2 0
2 1 1
3 2 3
69 69 69
2017 10 18
5 7 0
Output
6
1
15
699496932
892852568
713939942
----------------------------------------------------------------------------------------------------
