数论题。

首先我们知道公式:1^4+2^4+3^4+……+n^4=(n)*(n+1)*(2*n+1)*(3*n*n+3*n-1) /30;

然后我们要把多余的减掉。这里用到的是mobius反演。

总之就是加加减减就可以出答案了。

#include <iostream>
#include <cstring>
#include <cstdio>
#define ll long long
#define M 1000000007
using namespace std; ll power(ll x,ll y)
{
ll tot=;
while (y)
{
if (y&) tot=(tot*x)%M;
x=(x*x)%M;
y>>=;
}
return tot;
} ll over=power(,M-); ll count(ll x)
{
ll ans=x;
ans=(ans*(x+))%M;
ans=(ans*(*x+))%M;
ll tep=(*x*x+*x-)%M;
ans=(ans*tep)%M;
ans=(ans*over)%M;
return ans;
} ll sqrr(ll x)
{
return (x*x)%M;
} ll mobi(ll x)
{
ll k=x,tot=;
for (ll i=; i*i<=k; i++)
{
if (k%i==)
{
if (k%(i*i)==) return ;
tot++,k/=i;
}
}
if (k>) tot++;
if (tot&) return ;
return -;
} int main()
{
ll t,n,ans;
scanf("%I64d",&t);
while (t--)
{
scanf("%I64d",&n);
ans=count(n-);
for (int i=; i*i<=n; i++)
if (n%i==)
{
ll tep=sqrr(sqrr(i))*count(n/i-);
tep%=M;
ans=(ans-mobi(i)*tep)%M;
if (i*i==n) continue; tep=sqrr(sqrr(n/i))*count(i-);
tep%=M;
ans=(ans-mobi(n/i)*tep)%M;
}
printf("%I64d\n",(ans+M)%M);
}
return ;
}

HDU4059_The Boss on Mars的更多相关文章

  1. hdu4059 The Boss on Mars(差分+容斥原理)

    题意: 求小于n (1 ≤ n ≤ 10^8)的数中,与n互质的数的四次方和. 知识点: 差分: 一阶差分: 设  则    为一阶差分. 二阶差分: n阶差分:     且可推出    性质: 1. ...

  2. HDU 4059 The Boss on Mars 容斥原理

    The Boss on Mars Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  3. hdu4059 The Boss on Mars

    The Boss on Mars Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  4. HDU 4059 The Boss on Mars(容斥原理 + 四次方求和)

    传送门 The Boss on Mars Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Oth ...

  5. 数论 + 容斥 - HDU 4059 The Boss on Mars

    The Boss on Mars Problem's Link Mean: 给定一个整数n,求1~n中所有与n互质的数的四次方的和.(1<=n<=1e8) analyse: 看似简单,倘若 ...

  6. The Boss on Mars

    The Boss on Mars Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  7. HDU 4059 The Boss on Mars(容斥原理)

    The Boss on Mars Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  8. hdu 4059 The Boss on Mars

    The Boss on Mars Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  9. hdu4059 The Boss on Mars 容斥原理

    On Mars, there is a huge company called ACM (A huge Company on Mars), and it’s owned by a younger bo ...

随机推荐

  1. 20155222 2016-2017-2《Java程序设计》课程总结

    20155222 2016-2017-2<Java程序设计>课程总结 每周作业链接汇总 预备作业1:期望的师生关系 预备作业2:技能获取与语言学习 预备作业3:安装虚拟机及学习linux系 ...

  2. 20155316 实验四 《Android程序设计》

    实验1 实验内容 Android Stuidio的安装测试: 参考<Java和Android开发学习指南(第二版)(EPUBIT,Java for Android 2nd)>第二十四章: ...

  3. python append extend区别

    1. 列表可包含任何数据类型的元素,单个列表中的元素无须全为同一类型. 2. append() 方法向列表的尾部添加一个新的元素. 3. 列表是以类的形式实现的.“创建”列表实际上是将一个类实例化.因 ...

  4. echarts y轴,显示数据,但不显示竖线

    在yAxis中插入: axisLine: {show:false}, axisTick: {show:false}, yAxis : [ { show:true, axisLine: {show:fa ...

  5. 【原创】Odoo开发文档学习之:ORM API接口(ORM API)(边Google翻译边学习)

    官方ORM API开发文档:https://www.odoo.com/documentation/10.0/reference/orm.html Recordsets(记录集) New in vers ...

  6. 监听Entity Framework生成的Sql语句

               Entity Framework为我们提供了很大的方便,但有时候,我们想看看EF生成的Sql语句到底是怎样的,一种方式是我们可以启用Sql Server Profer工具.今天介 ...

  7. Sublime Text3添加右键

    在Sublime Text3安装目录下新建一个文件 sublime_addright.inf 文件内容: [Version] Signature="$Windows NT$" [D ...

  8. VR中射线点击按钮的实现

    VR中实现UI的Button点击,主要是需要实现IPointerClickHandler接口,因为在Unity将所有的按钮操作都封装成了相应的接口,需要相应的功能只需要去实现对应的接口就好了.在这里我 ...

  9. 在PHP中,是以分好结束一条语句的吗

    在PHP中,是以分号结束一条语句的,这个和C语言类似. 但是,有一条例外,对于PHP结束tag之前的语句,是可以不写分号的: <?php if ($a == $b) { echo "R ...

  10. Kotlin 学习笔记(一)

    (Kotlin 学习笔记的文档结构基本按照 Java 核心技术一书的目录排列) 基本程序设计结构 数据类型 数字 类型 宽度 Double 64 Float 32 Long 64 Int 32 Sho ...