26 条题解

  • 0
    @ 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;
    }

  • 0
    @ 2014-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

  • 0
    @ 2014-11-01 18:47:19

    ...

  • -1
    @ 2015-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;
    }

  • -1
    @ 2015-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;
    }

    • @ 2016-10-02 23:02:43

      for(int i=1;i<=l;i++) 这一句真的不应该改成

      for(int i=0;i<l;i++) 吗...(神犇别打我啊qwq)
      附结果

      编译成功

      测试数据 #0: WrongAnswer, time = 0 ms, mem = 572 KiB, score = 0

      测试数据 #1: WrongAnswer, time = 0 ms, mem = 576 KiB, score = 0

      测试数据 #2: WrongAnswer, time = 0 ms, mem = 572 KiB, score = 0

      测试数据 #3: WrongAnswer, time = 0 ms, mem = 576 KiB, score = 0

      测试数据 #4: WrongAnswer, time = 15 ms, mem = 576 KiB, score = 0

      测试数据 #5: WrongAnswer, time = 15 ms, mem = 576 KiB, score = 0

      测试数据 #6: WrongAnswer, time = 31 ms, mem = 576 KiB, score = 0

      测试数据 #7: WrongAnswer, time = 31 ms, mem = 572 KiB, score = 0

      测试数据 #8: WrongAnswer, time = 31 ms, mem = 576 KiB, score = 0

      测试数据 #9: Accepted, time = 15 ms, mem = 576 KiB, score = 10

      WrongAnswer, time = 138 ms, mem = 576 KiB, score = 10

    • @ 2016-10-02 23:03:41

      好吧是本辣鸡眼残了 神犇原谅我qwq

    • @ 2016-10-06 19:04:50

      请问string s;是什么意思

  • -1
    @ 2015-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
上传者