Advertisement
Guest User

Untitled

a guest
Dec 19th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.88 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4. //char data[600];
  5. int main(){
  6.     int len,n,count;
  7.     int countM,countA,countR,countG,countI,countT;
  8.     string data;
  9.     scanf("%d",&n); //幾筆測資
  10.     //len = strlen(n);
  11.     while(n--){
  12.         //scanf("%s",&data);
  13.         cin >> data;
  14.         len=data.length();
  15.         countM=0,countA=0,countR=0,countG=0,countI=0,countT=0;
  16.         for(int i=0;i<len;i++){
  17.             if(data[i]=='M')
  18.                 countM++;
  19.             if(data[i]=='A')
  20.                 countA++;
  21.             if(data[i]=='R')
  22.                 countR++;
  23.             if(data[i]=='G')
  24.                 countG++;
  25.             if(data[i]=='I')
  26.                 countI++;
  27.             if(data[i]=='T')
  28.                 countT++;          
  29.         }
  30.         count=0;
  31.         while(1){
  32.             if(countM>=1 && countA>=3 && countR>=2 && countG>=1 && countI>=1 && countT>=1){
  33.                 count++;
  34.                 countM-=1;
  35.                 countA-=3;
  36.                 countR-=2;
  37.                 countG-=1;
  38.                 countI-=1;
  39.                 countT-=1;
  40.             }
  41.             else
  42.                 break;
  43.         }
  44.         printf("%d\n",count);
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement