cf/mirror

Maximum GCD Sum Queries

CF
1973F3100· legendary gm5s512 MB⌨ stdin/stdout

Examples

Sample 1of 3
Input
3 4
1 2 3
4 5 6
1 1 1
0 1 2 3
Output
2 3 3 3
Sample 2of 3
Input
5 5
3 4 6 8 4
8 3 4 9 3
10 20 30 40 50
5 55 13 1000 113
Output
2 7 3 7 7
Sample 3of 3
Input
1 1
3
4
5
0
Output
7
1973F.cpp
loading editor…
Ln 11·137 BGNU C++20 (64)