希望大家别犯和我一样的错误
查看原帖
希望大家别犯和我一样的错误
72784
ljk_Elaina楼主2021/10/20 00:39
#include<bits/stdc++.h>
using namespace std;

typedef long long LL;
const LL MOD=998244353;

template<typename node> void read(node &a){
	bool f=0;
	LL x=0;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=((x<<1)%MOD+(x<<3)%MOD+(ch^48))%MOD;
		ch=getchar();
	}
	a=x;
	if(f) a=-a;
}

int n,m;
LL a[110];
int q[110],cnt;

inline bool work(LL x){
	LL ans=0;
	for(int i=n;i;i--)
		ans=((ans+a[i])*x)%MOD;
	ans=(ans+a[0])%MOD;
	return !ans;
}

int main(){
//	freopen("P2312_2.in","r",stdin);
	cout.tie(0);
	read(n);read(m);
	for(int i=0;i<n+1;i++) read(a[i]);
//	cout<<"Step1"<<endl;
	for(LL i=1;i<=m;i++)
		if(work(i))
			q[++cnt]=i;
	cout<<cnt<<endl;
	for(int i=1;i<=cnt;i++) cout<<q[i]<<endl;
	return 0;
}

估计没几个人能查出我的错。。。

错误就在

ch^48

这里忘打括号了

+,,×,÷+,-,\times,\div的优先级大于左右移,与,或和异或运算,所以记住加括号!!!

2021/10/20 00:39
加载中...