记录编号 489684 评测结果 AAAAAAAAAA
题目名称 数论函数簇 最终得分 100
用户昵称 GravatarLadyLex 是否通过 通过
代码语言 C++ 运行时间 3.214 s
提交时间 2018-03-04 16:26:22 内存使用 4.07 MiB
显示代码纯文本
  1. #include <cstdio>
  2. #include <cstring>
  3. #include <cmath>
  4. using namespace std;
  5. #define LL long long
  6. #define mod 1005060097
  7. #define inv2 502530049
  8. #define RG register
  9. inline LL gsum(LL l,LL r)
  10. {
  11. LL ret=(l+r)%mod;
  12. ret=(r-l+1)%mod*ret%mod;
  13. return ret*inv2%mod;
  14. }
  15. inline LL calc(int n)
  16. {
  17. LL i,last,ret=0;
  18. for(i=1;i<=n;i=last+1)
  19. last=n/(n/i),ret=(ret+ ( (i+last)*(last-i+1)/2 )%mod*(n/i)%mod/* gsum(i,last)%mod*/)%mod;
  20. return ret;
  21. }
  22. #define N 1000010
  23. int mu[N],prime[N/5],tot,lim;
  24. bool vis[N];
  25. LL n;
  26. inline void init()
  27. {
  28. RG int i,j,tmp;lim=sqrt(n);
  29. for(mu[1]=1,i=2;i<=lim;++i)
  30. {
  31. if(!vis[i])prime[++tot]=i,mu[i]=mod-1;
  32. for(j=1;(tmp=i*prime[j])<=lim;++j)
  33. {
  34. vis[tmp]=1;
  35. if(i%prime[j]==0){mu[tmp]=0;break;}
  36. mu[tmp]=mod-mu[i];
  37. }
  38. }
  39. }
  40. signed main()
  41. {
  42. // freopen("Ark.in","r",stdin);
  43. // printf("%d\n",calc(2) );
  44. freopen("functiona.in","r",stdin);
  45. freopen("functiona.out","w",stdout);
  46. RG int ans=0;RG LL i;
  47. scanf("%lld",&n);
  48. init();
  49. for(i=1;i*i<=n;++i)
  50. ans=(ans+ i*mu[i]%mod*calc( n/(i*i) )%mod )%mod;
  51. printf("%lld\n",(ans-( n*(n+1)/2 )%mod+mod)%mod);
  52. // printf("%lld\n",(ans-gsum(1,n)+mod)%mod);
  53. }
  54. //60000000000
  55. //181604926