题目
解题思路
[problem 1] 简单的模拟
[problem 2] 用桶排暴力算一算
代码(node_1)
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int a,b; bool c=1; char s;
int main()
{
while (1)
{
s=getchar();
if (s>='0'&&s<='9'&&c) {
a=(a<<3)+(a<<1)+s-'0';
if (a > 1e8) return !printf("Large");
} else
if (s>='0'&&s<='9'&&!c) {
b=(b<<3)+(b<<1)+s-'0';
if (b > 1e8) return ! printf("Large");
} else
if (s=='+') c=0; else
if (s!=' ') {
if (a+b<=1e8) printf("%d",a+b); else printf("Large");
return 0;
}
}
}
代码(node_2)
#include<cstdio>
#define rr register
#define LL long long
using namespace std;
const LL ymw=11111111;
int n,a,b,c,ans,len; bool t[ymw];
int main()
{
scanf("%d%d%d%d",&n,&a,&b,&c);
for (rr LL i=1;i<=n;i++)
t[(int)(((LL)(a*i*i)+(LL)(b*i)+(LL)(c))%ymw)]=1;
for (rr LL i=0;i<ymw;i++)
if (t[i]) ans=(int)(((LL)(ans)+(LL)(++len)*i)%ymw);
printf("%d",ans);
}