- 学姐的清晨问候
- 2017-07-13 16:21:06 @
WTF ! Does this break down ?
#include<iostream>
#include<cstring>
#include<cstdio>
#define INF (0x3f3f3f3f)
using namespace std;
int T;
int main () {
ios::sync_with_stdio(false);
scanf("%d",&T);
char Str[1010];
int StrLen;
for(int i=1;i<=T;i++) {
int CharCnt[128],finishCnt=INF;
memset(CharCnt,0,sizeof(CharCnt));
memset(Str,0,sizeof(Str));
cin.getline(Str,1010);
StrLen=strlen(Str);
for(int i=0;i<StrLen;i++)
CharCnt[(int)Str[i]]++;
finishCnt=min(finishCnt,CharCnt[(int)'g']/2);
finishCnt=min(finishCnt,CharCnt[(int)'o']/3);
finishCnt=min(finishCnt,CharCnt[(int)'d']);
finishCnt=min(finishCnt,CharCnt[(int)' ']);
finishCnt=min(finishCnt,CharCnt[(int)'m']);
finishCnt=min(finishCnt,CharCnt[(int)'r']);
finishCnt=min(finishCnt,CharCnt[(int)'n']/2);
finishCnt=min(finishCnt,CharCnt[(int)'i']);
printf("Case #%d: %d\n",i,finishCnt);
}
return 0;
}
2 条评论
-
z20c12h LV 9 @ 2017-07-20 21:05:37
唔,有空格啊。
-
2017-07-13 17:53:08@
#include<iostream> #include<cstring> #include<cstdio> #include<algorithm> #define INF (0x3f3f3f3f) using namespace std; int T; int main() { scanf("%d", &T); char c = getchar(); while (c != '\n')getchar(); char Str[1010]; int StrLen; for (int i = 1; i <= T; i++) { int CharCnt[128], finishCnt = INF; memset(CharCnt, 0, sizeof(CharCnt)); memset(Str, 0, sizeof(Str)); cin.getline(Str, 1010); StrLen = strlen(Str); for (int i = 0; i<StrLen; i++) CharCnt[(int)Str[i]]++; finishCnt = min(finishCnt, CharCnt[(int)'g'] / 2); finishCnt = min(finishCnt, CharCnt[(int)'o'] / 3); finishCnt = min(finishCnt, CharCnt[(int)'d']); finishCnt = min(finishCnt, CharCnt[(int)' ']); finishCnt = min(finishCnt, CharCnt[(int)'m']); finishCnt = min(finishCnt, CharCnt[(int)'r']); finishCnt = min(finishCnt, CharCnt[(int)'n'] / 2); finishCnt = min(finishCnt, CharCnt[(int)'i']); printf("Case #%d: %d\n", i, finishCnt); } return 0; }
- 1
信息
- ID
- 1902
- 难度
- 7
- 分类
- (无)
- 标签
- (无)
- 递交数
- 1572
- 已通过
- 340
- 通过率
- 22%
- 被复制
- 6
- 上传者