chirag2505's blog

By chirag2505, history, 23 months ago, In English

Given an array of integers A of length N. For each index i, find number of indices j(j!=i) such that gcd(A[i],A[j])>1.

Constraints:
N<=1e5
1<=A[i]<=N

Example:

  1. A = [4,3,2,4] output = [2,0,2,2]

  2. A = [2,3,6,4,6,5] output = [3,2,4,3,4,0]

Full text and comments »

  • Vote: I like it
  • +11
  • Vote: I do not like it

By chirag2505, history, 3 years ago, In English

Hello Codeforces!

I have a doubt in today contest problem A :(https://codeforces.com/contest/1557/problem/A)

I submitted solution in which I have used accumulate function to get sum of all elements of vector but it gave me WA.

And finally I got AC in which I find sum by traversing all elements.

Is there any difference in both methods to get sum of all elements of vector?

Here are the links of my both submissions :

125393659 — WA

125396830 — AC

Please help me to find out the error in code(using accumulate function).

Thanks in advance:)

UPD : Resolved

Full text and comments »

  • Vote: I like it
  • -7
  • Vote: I do not like it