# codeforces 933D A Creative Cutout

 1 #include <bits/stdc++.h>
2 #define il inline
3 #define RG register
4 #define ll long long
5 #define N (1000005)
6 #define rhl (1000000007)
7
8 using namespace std;
9
10 ll sum2[N],sum4[N],sum6[N],n,m,lim,ans;
11
12 il ll qpow(RG ll a,RG ll b){
13   RG ll ans=1;
14   while (b){
15     if (b&1) ans=ans*a%rhl;
16     if (b>>=1) a=a*a%rhl;
17   }
18   return ans;
19 }
20
21 int main(){
22 #ifndef ONLINE_JUDGE
23   freopen("cutout.in","r",stdin);
24   freopen("cutout.out","w",stdout);
25 #endif
26   cin>>n,m=n%rhl,lim=sqrt(n);
27   for (RG ll i=1;i<=lim;++i){
28     sum2[i]=(sum2[i-1]+i*i)%rhl;
29     sum4[i]=(sum4[i-1]+qpow(i,4))%rhl;
30     sum6[i]=(sum6[i-1]+qpow(i,6))%rhl;
31   }
32   for (RG ll x=-lim,y,x2,x4,x6,res;x<=lim;++x){
33     y=sqrt(n-x*x),x2=qpow(x,2),x4=qpow(x,4),x6=qpow(x,6),res=0;
34     (res+=m*(m+1)%rhl*(m+2)+2*x6-3*(m+2)*x4+(3*m+4)*x2)%=rhl;
35     (ans+=12*x4%rhl*sum2[y]+12*x2%rhl*sum4[y]+4*sum6[y])%=rhl;
36     (ans-=12*(m+2)%rhl*x2%rhl*sum2[y])%=rhl;
37     (ans-=6*(m+2)%rhl*sum4[y])%=rhl;
38     (ans+=2*(3*m+4)*sum2[y]+res*(2*y+1))%=rhl;
39   }
40   cout<<(ans+rhl)*((rhl+1)/2)%rhl*((rhl+1)/3)%rhl; return 0;
41 }

posted @ 2018-04-06 19:12  wfj_2048  阅读(557)  评论(0编辑  收藏  举报