Friday, March 21, 2014

Topcoder SRM 613 DIV 2 L1 TaroString

// Topcoder SRM 613 DIV 2 L1 TaroString

import java.util.*;
import java.math.*;

//rename the class name before submitting
public class TaroString {
public static void main(String[] args) {
TaroString obj = new TaroString();
System.out.println(
obj.getAnswer(
""
));
}

public String getAnswer(String S) {
String x = "";
for (int i = 0; i < S.length(); i++) {
if (S.charAt(i) == 'C')
x += "C";
if (S.charAt(i) == 'A')
x += "A";
if (S.charAt(i) == 'T')
x += "T";
}
if (x.equals("CAT"))
return "Possible";
else
return "Impossible";
}

public static int GetPrice(char c) {
int price;
if (c >= '0' && c <= '9')
price = c - '0';
else if (c >= 'A' && c <= 'Z')
price = 10 + c - 'A';
else
price = 36 + c - 'a';
return price;
}
}

No comments:

Post a Comment