XandreasrektsX

Seven Wonders

Oct 7th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #include<iostream>
  2. #include<algorithm>
  3. using namespace std;
  4.  
  5. int main(){
  6.  
  7. string str;
  8.  
  9. cin >> str;
  10.  
  11. int sum = 0, cT=0, cC=0, cG=0, multi=0,smallest=0;
  12.  
  13. for(int i = 0; i<str.size(); i++){
  14. if(str[i] == 'T'){
  15. cT++;
  16. }
  17. if(str[i] == 'C'){
  18. cC++;
  19. }
  20. if(str[i] == 'G'){
  21. cG++;
  22. }
  23.  
  24.  
  25. }
  26.  
  27. sum = (cG * cG) + (cC * cC) + (cT * cT);
  28.  
  29. if(cG < cC && cG < cT){
  30. smallest = cG;
  31. }
  32. else if(cC < cG && cC < cT){
  33. smallest = cC;
  34. }
  35. else if(cT < cC && cT < cG){
  36. smallest = cT;
  37. }
  38. if(smallest == 0 && cG == cC && cG == cT && cT == cC){
  39. smallest = cT;
  40. }
  41.  
  42. cout << (smallest * 7) + sum;
  43.  
  44. }
Advertisement
Add Comment
Please, Sign In to add comment