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:||ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.3.2, CPP 6.3, CPP14, CS2, D, ERL, FORT, FS, GO, HASK, ICK, ICON, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, NODEJS, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYPY, PYTH, PYTH 3.5, RUBY, SCALA, SCM chicken, SCM guile, SCM qobi, ST, TCL, TEXT, WSPC|
Fetching successful submissions
If you are still having problems, see a sample solution here.