import java.util.Scanner;
//10550
public class CombinationLock {
static int val1, val2, val3, val4;
static int sum;
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
while(true) {
val1 = scanner.nextInt();
val2 = scanner.nextInt();
val3 = scanner.nextInt();
val4 = scanner.nextInt();
if((val1 == val2) && (val2 == val3) && (val3 == val4) && (val4 == 0)) break;
sum = val1 - val2;
if(val1 < val2) {
sum += 40;
}
sum += (val3 - val2);
if(val2 > val3) {
sum += 40;
}
sum += (val3 - val4);
if(val3 < val4) {
sum += 40;
}
System.out.println((sum + 120) * 9);
}
scanner.close();
}
}
10/08/2013
10550 - Combination Lock - Java
10550 - Combination Lock - Java
Subscribe to:
Post Comments (Atom)
package Package1;
ReplyDeleteimport java.util.Scanner;
import java.math.*;
public class Uva10550 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int a =1,b=1,c=1,d=1;
int s1,s2,s3,sum;
while((a = in.nextInt())!=0 | (b = in.nextInt())!=0 | (c = in.nextInt())!=0 | (d= in.nextInt())!=0){
sum = 1080;
if(a<b){ sum += (40-b+a)*9;
}else sum+= (a-b)*9;
if(b<c) {sum+= (c - b)*9;
}else sum+= (40 - b + c)*9;
if(c<d) {sum+= (40 - d + c)*9;
}else sum+= (c - d)*9;
System.out.println(sum);
//System.out.println( (360*3+(s1+s2+s3)) );
}
}
}
why this code is wrong ???