Friday, November 24, 2017

Seven Wonders Kattis Problem Solution In Java

//Nayeem Shahriar Joy,Applied Physics & Electronic Engineering, University of Rajshahi.
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
public class Joy{
public static void main(String[] args) {
Scanner io = new Scanner(System.in);
String s=io.nextLine();
long ans=0;
int C=0,T=0,G=0;
for(int i=0;i<s.length();i++)
{
char c=s.charAt(i);
if(c=='T')
{
T++;
}
else if(c=='G')
{
G++;
}
else if(c=='C')
{
C++;
}
}
int seven=Math.min(T, Math.min(C,G));
ans=(T*T)+(C*C)+(G*G)+(seven*7);
System.out.println(ans);
}
}

No comments:

Post a Comment