比赛 暑假综合模拟2 评测结果 AAAAAAAAAA
题目名称 解方程 最终得分 100
用户昵称 jekyll 运行时间 0.674 s
代码语言 C++ 内存使用 0.77 MiB
提交时间 2018-08-04 21:01:47
显示代码纯文本
#include<cstdio>
#include<iostream>
#include<cstring>

using namespace std;

typedef long long ll;
const int mo1 = 1e4 + 7;
const int mo2 = 1e8 + 7;

ll n, m, ans;
ll a[105], b[105];
bool ok1[1000005], ok2[10010];
char s[10005];

int clac(int x, ll a[], int mo)
{
    ll ans = 0;
    for (int i = n; i >= 0; --i)
        ans = (ans * x + a[i]) % mo;
    return ans;
}

void read(ll& x, ll &y)
{
    char ch = getchar(); int w = 0; x = 0, y = 0;
    while (ch < '0' || ch > '9') w = w | ch == '-', ch = getchar();
    while (ch >= '0' && ch <= '9')
    x = ((x<<1) + (x<<3) + (ch^48)) % mo1, y = ((y<<1) + (y<<3) + (ch^48)) % mo2, ch = getchar();
    if (w) x = -x, y = -y;
}

int main()
{
	freopen("equationa.in", "r", stdin);
	freopen("equationa.out", "w", stdout);
    cin >> n >> m;
    for (int i = 0; i <= n; i++)
        read(a[i], b[i]);
    for (int i = 1; i < mo1; i++) if(!clac(i, a, mo1)) ok2[i] = 1;
    for (int i = 1; i <= m; i++) if(ok2[i % mo1]) if(!clac(i, b, mo2)) ++ans, ok1[i] = 1;
    printf("%lld\n", ans);
    for (int i = 1; i <= m; i++)
        if(ok1[i]) printf("%d\n", i);
}