L i n k Link Link
D
e
s
c
r
i
p
t
i
o
n
Description
Description ![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/30288daa28d54fecdbf49f7c78f9cf4b.png)
T r a i n Train Train o f of of T h o u g h t Thought Thought
直接暴力求出每一个数,然后模拟即可
C o d e Code Code
//#pragma GCC optimize("O2")
//#pragma GCC optimize("O3")
#include<cstdio>
#define ll long long
#define rr register
using namespace std;
const ll tot=11111111;
long long a,b,c,n,ans,len;
bool t[tot];
int main()
{
scanf("%lld%lld%lld%lld",&n,&a,&b,&c);
for (rr int i=1; i<=n%tot; ++i)//n大于tot求出的答案求余后和n小于tot时的数时一样的
t[(a*i*i+b*i+c)%tot]=1;//记录
for (rr int i=0; i<tot; ++i)
if (t[i]) ans=(ans+(++len)*i)%tot;//len是模拟题目中的1~m
printf("%lld",ans);
}