Cman and Candies
All submissions for this problem are available.
Cman doesn’t love bitwise operations anymore. He loves Alisha. Alisha is cute :). Cman know that most of all Alisha loves candies, that's why he bought N candies for her. Cost of ith candy is C[i]. Happiness associated with ith candy is defined as :
A[i]=C[i] if i=1
A[i]=(Σ |C[i] - C[j]| for j = 1 to i - 1) % 10^9+7 if 2<=i<=N
Cman wants to know the happiness associated with each candy. Help him to find solution to this problem.
Note: |X| is same as absolute value of X
- First line of input consists of a single integer T representing number of test cases.
- First line of each test case contains a space separated integer N.
- Next line consist of N space separated integer C, C, . . , C[N] denoting cost of candies.
For each test case print a single line containing N space separated integers A, A, . . , A[N] where A[i] denotes happiness of ith candy.
- 1 ≤ T ≤ 10
- 1 ≤ N ≤ 105
- 1 ≤ C[i] ≤ 105
Note: Order of candies should remain same i.e A[i] denotes happiness for ith candy in the given array having cost C[i]
Input: 1 3 1 2 3 Output: 1 1 3
|Time Limit:||2 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, PYP3, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.