Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- using namespace std;
- //char data[600];
- int main(){
- int len,n,count;
- int countM,countA,countR,countG,countI,countT;
- string data;
- scanf("%d",&n); //幾筆測資
- //len = strlen(n);
- while(n--){
- //scanf("%s",&data);
- cin >> data;
- len=data.length();
- countM=0,countA=0,countR=0,countG=0,countI=0,countT=0;
- for(int i=0;i<len;i++){
- if(data[i]=='M')
- countM++;
- if(data[i]=='A')
- countA++;
- if(data[i]=='R')
- countR++;
- if(data[i]=='G')
- countG++;
- if(data[i]=='I')
- countI++;
- if(data[i]=='T')
- countT++;
- }
- count=0;
- while(1){
- if(countM>=1 && countA>=3 && countR>=2 && countG>=1 && countI>=1 && countT>=1){
- count++;
- countM-=1;
- countA-=3;
- countR-=2;
- countG-=1;
- countI-=1;
- countT-=1;
- }
- else
- break;
- }
- printf("%d\n",count);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement