数论题。

首先我们知道公式: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. 20155339 《信息安全技术》实验二、Windows口令破解实验报告

    20155339 <信息安全技术>实验二.Windows口令破解实验报告 实验目的 了解Windows口令破解原理 对信息安全有直观感性认识 能够运用工具实现口令破解 系统环境 Windo ...

  2. 1018: [SHOI2008]堵塞的交通traffic

    1018: [SHOI2008]堵塞的交通traffic 链接 分析: 用线段树维护区间的四个端点的联通情况,然后查询的时候,把所有覆盖到的区间合并起来即可. 六种情况左上到右上(左边到右边的情况)… ...

  3. spring源码-aop增强-5.2

    一.aop增强就是针对于不同的切面进行的相关增强,目的当然是更好的支持相关应用和解耦. 二.默认的aop增强类有AspectJMethodBeforeAdvice.AspectJMethodBefor ...

  4. Arduino 101/Genuino101使用-第2篇

    1. Arduino 101编程只是在ARC的核心上进行,其具体架构为ARCv2EM.. 2. 而Quark核心,从目前可知的信息来看,其应该运行着名为Zephyr的RTOS 3.101并没有EEPR ...

  5. SQL查找重复项目

    1 2 3 4 5 6 7 SELECT t1.* FROM t1,   (SELECT name,ADD    FROM t1    GROUP BY name,ADD HAVING COUNT(1 ...

  6. 使用GitLab创建项目

  7. IDEA 配置Junit4

    Junit4 主要用来执行java程序的单元测试: 1 安装junit4插件 因为我安装过了,没有安装的再输入框搜索,然后安装就行 2 选择默认使用Junit4 3 红框中的test去掉,变为“$en ...

  8. socket编程为什么需要htonl(), ntohl(), ntohs(),htons() 函数-------转载

    在C/C++写网络程序的时候,往往会遇到字节的网络顺序和主机顺序的问题.这是就可能用到htons(), ntohl(), ntohs(),htons()这4个函数. 网络字节顺序与本地字节顺序之间的转 ...

  9. 经典教程|10 分钟速成 Python3

    Python 是由吉多·范罗苏姆(Guido Van Rossum)在 90 年代早期设计. 它是如今最常用的编程语言之一.它的语法简洁且优美,几乎就是可执行的伪代码. 注意:这篇教程是基于 Pyth ...

  10. PHP核心技术——魔术方法

    魔术方法: 魔术方法是以两个下画线开头.具有特殊作用的一些方法,可以看做PHP的"语法糖". set和get方法: class Account{ private $user=1; ...