Chef’s son Chefu found some matches in the kitchen and he immediately starting playing with them.
The first thing Chefu wanted to do was to calculate the result of his homework — the sum of A and B, and write it using matches. Help Chefu and tell him the number of matches needed to write the result.The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows.
The first and only line of each test case contains two space-separated integers A and B.
import java.util.Scanner;
public class MATCHISTICS {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
int t=input.nextInt();
int i=0;
while(i<t) {
int a=input.nextInt();
int b=input.nextInt();
int n=a+b;
match(n);
i++;
}
}
public static void match(int n) {
int total=0;
while(n!=0) {
int temp=n%10;
n=n/10;
if(temp==2||temp==3||temp==5) total=total+5;
else if(temp==6||temp==9) total=total+6;
else if(temp==1) total=total+2;
else if(temp==0) total=total+8;
else if(temp==4) total=total+4;
else if(temp==7) total=total+3;
else if(temp==8) total=total+7;
}
System.out.println(total);
}
}