题目:给你一些字符,问能组成几个MARGARITA。
分析:简单题。直接统计计算就可以。
说明:近期状态有点不稳定╮(╯▽╰)╭。
#include <algorithm> #include <iostream> #include <cstdlib> #include <cstring> #include <cstdio> #include <cmath> using namespace std; int main() { int n,count[6]; char buf[606]; while (~scanf("%d",&n)) { for (int i = 0; i < n; ++ i) { scanf("%s",buf); for (int j = 0; j < 6; ++ j) count[j] = 0; for (int j = 0; buf[j]; ++ j) { if (buf[j] == 'M') ++ count[0]; if (buf[j] == 'A') ++ count[1]; if (buf[j] == 'R') ++ count[2]; if (buf[j] == 'G') ++ count[3]; if (buf[j] == 'I') ++ count[4]; if (buf[j] == 'T') ++ count[5]; } count[1] /= 3; count[2] /= 2; int min = 606; for (int j = 0; j < 6; ++ j) if (min > count[j]) min = count[j]; printf("%d ",min); } } return 0; }