主页 讨论版 问题 名次 状态 统计

[提交][状态][讨论版]

## 题目描述

a[1]...a[n],(2 <= a[i] <= 100,000)
c[1]...c[n],(0 <= c[i] <= 100,000)

b1为a[1]...a[i-1]中与a[i]不互质的最小数字,如果不存在为0;
b2为a[1]...a[i-1]中与a[i]不互质的最大数字,如果不存在为0;

## 输入

n    : 1 <= n <= 10,000
a[i] : 2 <= a[i] <= 100,000
c[i] : 0 <= c[i] <= 100,000

```6
2 3 20 7 6 9
7 4 3 5 7 6
0```

## 样例输出

`0 0 7 0 19 11`

## 提示

i = 1 : b1 = 0, b2 = 0,   res[1] = 0;                                      此时val[a[1]] += c[1], 即val[2] += 7;

i = 2 : b1 = 0, b2 = 0,   res[2] = 0;                                      此时val[a[2]] += c[2], 即val[3] += 4;

i = 3 : b1 = 2, b2 = 2;   res[3] = val[2] = 7;                         此时val[a[3]] += c[3], 即val[20] += 3;

i = 4 : b1 = 0, b2 = 0;   res[4] = 0;                                      此时val[a[4]] += c[4], 即val[7] += 5;

i = 5 : b1 = 2, b2 = 20; res[5] = val[2] + ... + val[20] = 19;  此时val[a[5]] += c[5], 即val[6] += 7;

i = 6 : b1 = 3, b2 = 6;   res[6] = val[3] + ... + val[6]  = 11;   此时val[a[6]] += c[6], 即val[9] += 6;

[提交][状态][讨论版]