数论题。

首先我们知道公式: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. day6 网络 HTML模板

    1.HTML模板 HTML模板 baidu一下 http://www.cssmoban.com/ http://www.cnblogs.com/web-d/archive/2010/04/16/171 ...

  2. ELKStack入门篇(四)之Filebeat

    Filebeat是轻量级单用途的日志收集工具,用于在没有安装java的服务器上专门收集日志,可以将日志转发到logstash.elasticsearch或redis等场景中进行下一步处理. 官方文档: ...

  3. vcruntime140.dll 丢失64位系统

    1. 下载VC Redistributable for VS2015,网址https://www.microsoft.com/en-us/download/confirmation.aspx?id=4 ...

  4. Kettle数据源连接配置

    说明: 通过(图3.1)我们可以看到创建数据源时需要配置相应的参数: Connection Name(必填):配置数据源使用名称,如:Rot_Source Host Name(必填):数据库主机IP地 ...

  5. 解决WCF传输的数据量过大问题

    今天写了个WCF接口,然后自测通过,和别人联调时报 远程服务器返回错误: (413) Request Entity Too Large        错误!记得以前写的时候也出现过这个错误,大致解决办 ...

  6. MYSQL主从复制配置(整理)

    MYSQL主从原理及过程 原理 Mysql的 Replication 是一个异步的复制过程(mysql5.1.7以上版本分为异步复制和半同步两种模式),从一个 Mysql instace(我们称之为 ...

  7. Python基础灬函数(定义,参数)

    函数 函数定义 # 定义一个计算绝对值的函数 def cal_abs(x): if x >= 0: return x else: return -x # 调用函数 print('-1的绝对值是: ...

  8. HTML5+Bootstrap 学习笔记 3

    HTML5 aria-* and role aria是指Accessible Rich Internet Application.role的作用是描述一个非标准的tag的实际作用,而aria-*的作用 ...

  9. ES6的新特性(19)——Module 的语法

    Module 的语法 概述 历史上,JavaScript 一直没有模块(module)体系,无法将一个大程序拆分成互相依赖的小文件,再用简单的方法拼装起来.其他语言都有这项功能,比如 Ruby 的re ...

  10. TP框架代码学习 学习记录 3.2.3

    文件:think.class.php PHP提供register_shutdown_function()这个函数,能够在脚本终止前回调注册的函数,也就是当 PHP 程序执行完成后执行的函数.regis ...