标签:turn ret lld ++ open main ons lin base
只能在 luogu 上过,bz 上过不去~
复杂度 $O(n\times m)$
code:
#include <bits/stdc++.h> #define N 1000005 #define LL long long #define setIO(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout) using namespace std; // 0 ~ 15 const LL mod[]={998244353,19,1e9+7, 1e9+9, 233,233233,23,17,19,11,613317,119,911,2332,2323,1415,1717}; int n,m; char str[103][N]; vector<int>v; LL a[20][N]; int check(int tmp) { // 15 个模数 int i,j; for(i=0;i<=0;++i) { LL temp=0ll; a[i][n+1]=0ll; for(j=n+1;j>=0;--j) temp=(temp*1ll*tmp%mod[i]+a[i][j])%mod[i]; if(temp!=0) return 0; } return 1; } inline void Init() { int i,j; for(i=0;i<=0;++i) { for(j=0;j<=n;++j) { LL tmp=0,base=1ll; int len=strlen(str[j]); for(int k=len-1;k>=0;--k) { if(k==0&&str[j][k]==‘-‘) { tmp=(mod[i]-tmp%mod[i])%mod[i]; } else { tmp=(tmp+(str[j][k]-‘0‘)*base)%mod[i], base=base*10%mod[i]; } } a[i][j]=tmp; // printf("%d %lld\n",j,a[j]); } } } int main() { // setIO("input"); int i,j; scanf("%d%d",&n,&m); for(i=0;i<=n;++i) scanf("%s",str[i]); Init(); for(i=1;i<=m;++i) if(check(i)) v.push_back(i); printf("%d\n",v.size()); for(i=0;i<v.size();++i) printf("%d\n",v[i]); return 0; }
标签:turn ret lld ++ open main ons lin base
原文地址:https://www.cnblogs.com/guangheli/p/11801383.html