The problem is available at http://www.spoj.com/problems/NSTEPS/
The problem is very easy to solve.
solution is given below in java :
import java.util.Scanner;
import java.lang.*;
class spoj
{
public static void main(String args[])
{
Scanner s=new Scanner(System.in);
int count=s.nextInt();
int i=0;
int valx=0;
int valy=0;
while(i<count){
valx=s.nextInt();
valy=s.nextInt();
if(valx==valy){
if (valx % 2 == 0)
System.out.println(valx +valy);
else
System.out.println(valx +valx - 1);
}
else if(valy==(valx-2)){
if (valx % 2 == 0)
System.out.println(valx + valy);
else
System.out.println(valx + valy - 1);
}
else{
System.out.println("No Number");
}
i++;
}
}
}
The problem is very easy to solve.
solution is given below in java :
import java.util.Scanner;
import java.lang.*;
class spoj
{
public static void main(String args[])
{
Scanner s=new Scanner(System.in);
int count=s.nextInt();
int i=0;
int valx=0;
int valy=0;
while(i<count){
valx=s.nextInt();
valy=s.nextInt();
if(valx==valy){
if (valx % 2 == 0)
System.out.println(valx +valy);
else
System.out.println(valx +valx - 1);
}
else if(valy==(valx-2)){
if (valx % 2 == 0)
System.out.println(valx + valy);
else
System.out.println(valx + valy - 1);
}
else{
System.out.println("No Number");
}
i++;
}
}
}
No comments:
Post a Comment