什么鬼?!

编译成功
测试数据 #0: Accepted, time = 0 ms, mem = 4976 KiB, score = 10
测试数据 #1: Accepted, time = 0 ms, mem = 4976 KiB, score = 10
测试数据 #2: Accepted, time = 15 ms, mem = 4976 KiB, score = 10
测试数据 #3: Accepted, time = 46 ms, mem = 4980 KiB, score = 10
测试数据 #4: Accepted, time = 46 ms, mem = 4972 KiB, score = 10
测试数据 #5: Accepted, time = 125 ms, mem = 4980 KiB, score = 10
测试数据 #6: Accepted, time = 125 ms, mem = 4976 KiB, score = 10
测试数据 #7: Accepted, time = 93 ms, mem = 4972 KiB, score = 10
测试数据 #8: Accepted, time = 78 ms, mem = 4976 KiB, score = 10
测试数据 #9: WrongAnswer, time = 125 ms, mem = 4976 KiB, score = 0
WrongAnswer, time = 653 ms, mem = 4980 KiB, score = 90
代码

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;
#define maxn 1000010
const int prime[] = {10007,10917,30071};
int n,m;
long long a[110][5];
bool f[100000][5];
int cnt[maxn];
char s[10010];
bool calc(int value, int j) {
    long long tmp = 0;
    for (int i = n; i>=0; --i)
        tmp = (tmp * value + a[i][j]) % prime[j];
    return tmp != 0;
}
int main(){
    //freopen("equation.in", "r", stdin);
    //freopen("equation.out", "w", stdout);
    cin>>n>>m;
    for (int i = 0; i <= n; ++i) {
        scanf("%s", s);
        int len = strlen(s);
        int sign = 1;
        for (int l = 0; l < len; ++l) {
            if(s[l]=='-')
               sign = -1;
            else
                for (int j = 0; j < 3; ++j)
                    a[i][j]=( a[i][j] * 10 + s[l]-'0' ) % prime[j];
        }
        if (sign == -1)
           for (int j = 0; j < 3; ++j)
               a[i][j] = prime[j] - a[i][j];
    }
     
    for (int j = 0; j < 3; ++j)
        for(int i = 0; i < prime[j]; ++i)
            f[i][j]=calc(i,j);
         
    for (int i = 1; i <=m; ++i) {
        bool flag = true;
        for(int j = 0; j < 3; ++j)
            if(f[i % prime[j]][j]) {
                flag = false; break;
            }
        if(flag)
            cnt[++cnt[0]] = i;
    }
    printf("%d\n", cnt[0]);
    for (int i = 1; i <= cnt[0]; ++i)
        printf("%d\n",cnt[i]);
    return 0;
}

2 条评论

  • @ 2017-10-24 16:14:12

    求正解

  • @ 2017-10-24 16:13:39

    同上

    #1 Accepted 3ms 384.0 KiB
    #2 Accepted 3ms 372.0 KiB
    #3 Accepted 3ms 364.0 KiB
    #4 Accepted 3ms 368.0 KiB
    #5 Accepted 3ms 356.0 KiB
    #6 Accepted 31ms 356.0 KiB
    #7 Accepted 33ms 360.0 KiB
    #8 Accepted 488ms 384.0 KiB
    #9 Wrong Answer 448ms 384.0 KiB
    #10 Accepted 630ms 384.0 KiB

  • 1

信息

ID
1910
难度
7
分类
(无)
标签
递交数
2960
已通过
509
通过率
17%
被复制
7
上传者