CF1553F.Pairwise Modulo

提高+/省选-

通过率:0%

时间限制:4.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You have an array aa consisting of nn distinct positive integers, numbered from 11 to nn. Define pkp_k as $$p_k = \sum_{1 \le i, j \le k} a_i \bmod a_j,$$ where x mod yx \bmod y denotes the remainder when xx is divided by yy. You have to find and print p1,p2,…,pnp_1, p_2, \ldots, p_n.

你有一个由 nn 个互不相同的正整数组成的数组 aa,其元素编号从 11 到 nn。定义 pkp_k 为

p_k=sum_1lei,jleka_ibmoda_j,p\_k = \\sum\_{1 \\le i, j \\le k} a\_i \\bmod a\_j,

其中 x mod yx \bmod y 表示 xx 除以 yy 所得的余数。你需要求出并输出 p1,p2,…,pnp_1, p_2, \ldots, p_n。

输入格式

The first line contains nn — the length of the array (2≤n≤2⋅1052 \le n \le 2 \cdot 10^5).

The second line contains nn space-separated distinct integers a1,…,ana_1, \ldots, a_n (1≤ai≤3⋅1051 \le a_i \le 3 \cdot 10^5, ai≠aja_i \neq a_j if i≠ji \neq j).

第一行包含 nn —— 数组的长度(2≤n≤2⋅1052 \le n \le 2 \cdot 10^5)。

第二行包含 nn 个用空格分隔的互不相同的整数 a1,…,ana_1, \ldots, a_n(1≤ai≤3⋅1051 \le a_i \le 3 \cdot 10^5,当 i≠ji \neq j 时,ai≠aja_i \neq a_j)。

输出格式

Print nn integers p1,p2,…,pnp_1, p_2, \ldots, p_n.

输出 nn 个整数 p1,p2,…,pnp_1, p_2, \ldots, p_n。

输入输出样例

  • 输入#1

    4
    6 2 7 3

    输出#1

    0 2 12 22
  • 输入#2

    3
    3 2 1

    输出#2

    0 3 5

输入解题思路,AI测评打分。不知道怎么写?

首页