26 条题解
-
0CharlieYoung LV 7 @ 2014-11-02 09:13:31
80,T一个,W一个,为啥啊?
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;
const int maxn=1000+100;
int num[100];
string gm="g odmrni";//good morning
char lie[maxn];
int T;
void read()
{
char x=getchar();
int index=0;
while(x!='\n')
{
lie[index++]=x;
x=getchar();
}
}
void work(int t)
{
memset(num,0,sizeof(num));
for(int i=0;i<maxn;i++)
{
lie[i]='\0';
}
printf("Case #%d: ",t);
read();
int n=strlen(lie);
for(int i=0;i<n;i++)
{
for(int j=0;j<8;j++)
{
if(lie[i]==gm[j])
{
num[j]++;
break;
}
}
}int ans=0x3f3f3f3f;
for(int i=0;i<8;i++)//g odmrni good morning
{
if(i==0)num[i]/=2;
else if(i==2)num[i]/=3;
else if(i==6)num[i]/=2 ;
ans=min(ans,num[i]);
}printf("%d\n",ans);
}
void readdata()
{
scanf("%d\n",&T);
for(int i=1;i<=T;i++)
{
work(i);
}
}
int main()
{
readdata();
return 0;
} -
02014-11-01 22:40:07@
#include<cstdio>
#include<cstring>
int main()
{
int T,ch,ans,num[8];scanf("%d",&T);while((ch=getchar())==' ');
for(int kase=1;kase<=T;++kase)
{
printf("Case #%d: ",kase);
memset(num,0,sizeof(num));
for(;(ch=getchar())!=EOF;)
{
if(ch=='\n')break;
switch(ch)
{
case 'g':++num[0];break;
case 'o':++num[1];break;
case 'd':++num[2];break;
case ' ':++num[3];break;
case 'm':++num[4];break;
case 'r':++num[5];break;
case 'n':++num[6];break;
case 'i':++num[7];break;
default :break;
}
}
num[0]/=2;num[1]/=3;num[6]/=2;ans=1001;
for(int i=0;i<8;++i)if(num[i]<ans)ans=num[i];
printf("%d\n",ans);
}
return 0;
}AC 注意读入后有空格(组数后面)不然爆0 -
02014-11-01 18:47:19@
...
-
-12015-08-04 14:53:44@
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
int main()
{
int T,ch,ans,num[8];
scanf("%d",&T);
while((ch=getchar())==' ');
for(int kase=1;kase<=T;++kase)
{
printf("Case #%d: ",kase);
memset(num,0,sizeof(num));
for(;(ch=getchar())!=EOF;)
{
if(ch=='\n')break;
switch(ch)
{
case 'g':++num[0];break;
case 'o':++num[1];break;
case 'd':++num[2];break;
case ' ':++num[3];break;
case 'm':++num[4];break;
case 'r':++num[5];break;
case 'n':++num[6];break;
case 'i':++num[7];break;
default :break;
}
}
num[0]/=2;num[1]/=3;num[6]/=2;ans=1001;
for(int i=0;i<8;++i)if(num[i]<ans)ans=num[i];
printf("%d\n",ans);
}
return 0;
} #include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
int main()
{
int T,ch,ans,num[8];
scanf("%d",&T);
while((ch=getchar())==' ');
for(int kase=1;kase<=T;++kase)
{
printf("Case #%d: ",kase);
memset(num,0,sizeof(num));
for(;(ch=getchar())!=EOF;)
{
if(ch=='\n')break;
switch(ch)
{
case 'g':++num[0];break;
case 'o':++num[1];break;
case 'd':++num[2];break;
case ' ':++num[3];break;
case 'm':++num[4];break;
case 'r':++num[5];break;
case 'n':++num[6];break;
case 'i':++num[7];break;
default :break;
}
}
num[0]/=2;num[1]/=3;num[6]/=2;ans=1001;
for(int i=0;i<8;++i)if(num[i]<ans)ans=num[i];
printf("%d\n",ans);
}
return 0;
}#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
int main()
{
int T,ch,ans,num[8];
scanf("%d",&T);
while((ch=getchar())==' ');
for(int kase=1;kase<=T;++kase)
{
printf("Case #%d: ",kase);
memset(num,0,sizeof(num));
for(;(ch=getchar())!=EOF;)
{
if(ch=='\n')break;
switch(ch)
{
case 'g':++num[0];break;
case 'o':++num[1];break;
case 'd':++num[2];break;
case ' ':++num[3];break;
case 'm':++num[4];break;
case 'r':++num[5];break;
case 'n':++num[6];break;
case 'i':++num[7];break;
default :break;
}
}
num[0]/=2;num[1]/=3;num[6]/=2;ans=1001;
for(int i=0;i<8;++i)if(num[i]<ans)ans=num[i];
printf("%d\n",ans);
}
return 0;
} -
-12015-08-03 15:54:51@
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int n;
char c;
string s;
int a[10],ans;
int main()
{
scanf("%d",&n);
while((c=getchar())==' ');
for(int k=1;k<=n;k++)
{
memset(a,0,sizeof(a));
getline(cin,s);
int l=s.size();
for(int i=1;i<=l;i++)
{
if(s[i]==' ') a[1]++;
if(s[i]=='g') a[2]++;
if(s[i]=='o') a[3]++;
if(s[i]=='d') a[4]++;
if(s[i]=='m') a[5]++;
if(s[i]=='r') a[6]++;
if(s[i]=='n') a[7]++;
if(s[i]=='i') a[8]++;
}
a[2]/=2;
a[3]/=3;
a[7]/=2;
sort(a+1,a+9);
ans=a[1];
printf("Case #%d: %d\n",k,ans);
}
return 0;
} -
-12015-08-03 15:54:39@
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int n;
char c;
string s;
int a[10],ans;
int main()
{
scanf("%d",&n);
while((c=getchar())==' ');
for(int k=1;k<=n;k++)
{
memset(a,0,sizeof(a));
getline(cin,s);
int l=s.size();
for(int i=1;i<=l;i++)
{
if(s[i]==' ') a[1]++;
if(s[i]=='g') a[2]++;
if(s[i]=='o') a[3]++;
if(s[i]=='d') a[4]++;
if(s[i]=='m') a[5]++;
if(s[i]=='r') a[6]++;
if(s[i]=='n') a[7]++;
if(s[i]=='i') a[8]++;
}
a[2]/=2;
a[3]/=3;
a[7]/=2;
sort(a+1,a+9);
ans=a[1];
printf("Case #%d: %d\n",k,ans);
}
return 0;
}
信息
- ID
- 1902
- 难度
- 7
- 分类
- (无)
- 标签
- (无)
- 递交数
- 1572
- 已通过
- 340
- 通过率
- 22%
- 被复制
- 6
- 上传者