ALCATRAZ1 - SUM OF DIGITS


You are being given a number N. (1<=N<=10^50) . You have to print the sum of digits of that particular number. 

Input

The first line will contain T, the number of testcases (T<10) . The next T lines will contain the numbers whose sum of digits you have to calculate .  

Output

Output T lines  containing the Sum of Digits of the numbers .

Example

Input:
3
123123123
3434
1234567890

Output:
18
14
45

hide comments
navitas: 2018-02-11 18:31:26

use python

lannisterr: 2017-12-27 13:06:42

do we have to take 2D array for input of character?
@akhand_mishra

Last edit: 2017-12-27 13:07:33
akhand_mishra: 2017-12-22 14:05:08

@rushikeshkoli actually '0' =48

akhand_mishra: 2017-12-22 13:56:50

convert each character to integer and store in sum.
subtract with '0'
even you can subtract with 48 as ascii values of numbers start with it.
HOPE IT HELPS!!

Last edit: 2017-12-22 13:59:53
vikranth493: 2017-12-14 06:27:42

Still getting TLE eventhough using biginteger in java. Can any one help?

udxs: 2017-11-04 17:55:16

@mitacs subtract the character by 48 to convert the char code to a number.

mitacs: 2017-10-25 16:22:27

can anybody give me the solution of this problem by converting int into string in c

spaceman_spiff: 2017-10-13 20:52:42

In C++, Use a string STL. Lambdas will help. All you need to do is run a loop from 1 to 9 on the string.

anand2209: 2017-09-22 21:27:21

time limit exceeded ...using modulus and division method

Last edit: 2017-09-22 21:27:36
rushikeshkoli: 2017-09-04 07:36:48

why should we subtract '0'?


Added by:Alcatraz
Date:2016-11-04
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64 GOSU