First, solve the problem. Then, write the code. ” - John Johnson

It's not at all important to get it right the first time. It's vitally important to get it right the last time. ” - Andrew Hunt and David Thomas

Sunday, July 20, 2014

Banglawash.

Author : Jisan
Programming language : Java 
Difficulty : Easy
Status : Accepted
Problem number : UVA-12700
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4438

Code:

import java.util.*;
public class Uva_12700 {

public static void main(String[] args) {
Scanner in=new Scanner(System.in);
int cases=0;
while(in.hasNext()){
int a=in.nextInt();

for(int i=0;i<a;i++){
int matches=in.nextInt();
String jisan=in.next();
char[] tomato=jisan.toCharArray();
int A=0;
int B=0;
int T=0;
int W=0;
for(int q=0;q<matches;q++){
if(tomato[q]=='A'){
A++;
}else if(tomato[q]=='B'){
B++;
}else if(tomato[q]=='T'){
T++;
}else if(tomato[q]=='W'){
W++;
}
}
cases++;
if((B+A==matches) && A!=matches){
   System.out.println("Case "+cases+": "+"BANGLAWASH");
}else if((W+A==matches) && W!=0){
System.out.println("Case "+cases+": "+"WHITEWASH");
}else if(A==matches){
      System.out.println("Case "+cases+": "+"ABANDONED");
}else if(B>W){
      System.out.println("Case "+cases+": "+"BANGLADESH " +B+" - "+W);
  }else if(W>B){
      System.out.println("Case "+cases+": "+"WWW "+W+" - "+B);
     } else if(B==W){
      System.out.println("Case "+cases+": "+"DRAW "+B+" "+W);
}
   }
  }
 }
}

No comments:

Post a Comment