标签:turn string create template git ++ class end include
http://oi.nks.edu.cn/zh/Problem/Details?cid=529&tid=D
这题真的想不到
此题用了秦九韶算法
我明白了要去推才知道
否则不一定要用学过的 公式
关于模数 快读玄学优化 + 取模
code:
//
// main.cpp
// sif
//
// Created by ALEZ on 2019/9/8.
// Copyright ? 2019 比赛. All rights reserved.
//
#include<stdio.h>
#include<cstdio>
#include <stdlib.h>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<algorithm>
#include<queue>
#define mod 1000000007
#define maxnn 2000000
#define ll long long
using namespace std;
template<typename T>
#define ll long long
void rin(T &t)
{
t=0;int k=1;
char c=getchar();
while(!isdigit(c)){if(c=='-')k=-1;c=getchar();}
while(isdigit(c)){t=(t<<1)%mod+(t<<3)%mod+c-'0';c=getchar();}
t=(t*k)%mod;
}
ll n,a[maxnn],m;
ll pos[maxnn],iu=0;
queue<ll > C;
bool bfs(ll v){
for(int i=1;i<=iu;i++)
{
C.push(pos[i]);
}
ll a=C.front();C.pop();
ll tmp=a%mod;
while(C.size())
{
tmp=(tmp*v%mod)%mod;
ll s=C.front();
tmp=(tmp+s)%mod;
C.pop();
}
if(tmp==0) return true;
else return false;
}
queue <ll > K;
ll tot=0;
int main()
{
cin>>n>>m;
n++;
for(int i=1;i<=n;i++)
{
rin(a[i]);
}
for(int i=n;i>=1;i--)
{
iu++;
pos[iu]=a[i];
}
for(int i=1;i<=m;i++)
if(bfs(i))
{
tot++;
K.push(i);
}
cout<<tot<<endl;
while(K.size())
{
printf("%lld\n",K.front());
K.pop();
}
}
标签:turn string create template git ++ class end include
原文地址:https://www.cnblogs.com/OIEREDSION/p/11487361.html