[Login|Register]
New post

Show post

Search forum

Read post
此题测试数据格式有问题! [ Topic ] 2011-09-02 22:16:33 nuptxxp
我这个代码RE:
#include <iostream>

#include <cstdio>

#include <cstring>

using namespace std;

int a[10];

int main()
{
    int T;
    scanf("%d",&T);
    getchar();
    while(T--){
        memset(a,0,sizeof(a));
        //int sum=0;
        int ans=0;
        char c;
        while((c=getchar())!='\n'){
            a[c-'0']++;
        }
        while(((c=getchar())!='\n') && (c!=EOF)){
            for(int i=1;i<10;++i){
                ans+=a[i]*(i%(c-'0'));
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}

这个代码AC:
#include <iostream>

#include <cstdio>

#include <cstring>

using namespace std;

#define LIM 10000+20

char a[LIM];

int b[20];

int main()
{
    int T;
    scanf("%d",&T);
    //getchar();
    while(T--){
        memset(b,0,sizeof(b));
        //int sum=0;
        int ans=0;
        //char c;
        scanf("%s",a);
        for(int i=0;a[i] != '\0' ; ++i){
            b[a[i]-'0']++;
        }
        scanf("%s",a);
        for(int i=0;a[i]!='\0';++i){
            for(int j=1;j<10;++j){
                ans+=b[j]*(j%(a[i]-'0'));
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}
这说明什么?
很显然,测试数据两个数是以空格隔开(或者有多余的空格或空行)
而题目要求只是两行,没有说是用空格隔开
望管理员能认真对待测试数据
Reply
Title
Message
(64K)
University of Science and Technology of China
Online Judge for ACM/ICPC
Processed in 1.6ms with 2 query(s).