LED-URI- 1168

URI Online Judge | 1168

LED

Unknown Author
Timelimit: 1
John wants to set up a panel containing different numbers of LEDs. He does not have many leds, he is not sure if he will be able to mount the desired number. Considering the configuration of the LEDs of the numbers below, make an algorithm that helps John to discover the number of LEDs needed to set the value.

Input

The input contains an integer N, (1 ≤ N ≤ 2000) corresponding to the number of test cases, followed by N lines, each line containing a number (1 ≤ V ≤ 10100corresponding to the value that John wants to set with the leds.

Output

For each test case, print one line containing the number of LEDs that John needs to set the desired value, followed by the word "leds".
Input SampleOutput Sample
3
115380
2819311
23456
27 leds
29 leds
25 leds
Solution:

#include<bits/stdc++.h>
using namespace std;
int main()
{
string s;
int t,c,i,j;

cin>>t;
for(j=0;j<t;j++)
{
c=0;
cin>>s;
for( i=0;i<s.size();i++)
{
if(s[i]=='1')
c=c+2;
else if(s[i]=='2')
c=c+5;
else if(s[i]=='3')
c=c+5;
else if(s[i]=='4')
c=c+4;
else if(s[i]=='5')
c=c+5;
else if(s[i]=='6')
c=c+6;
else if(s[i]=='7')
c=c+3;
else if(s[i]=='8')
c=c+7;
else if(s[i]=='9')
c=c+6;
else if(s[i]=='0')
c=c+6;
}
printf("%d leds\n",c);
}
}

Comments