题目链接:https://projecteuler.net/problem=429

题目:

我们称 N 的约数 d 为特殊的当且仅当 gcd(d, n / d) = 1.

设 S(n) 为 n 所有特殊的约数的平方和. 现在给定 N, 求 S(N!) 模 1e7 + 9.

题解:

第二行的"所以 S(n2) "改成"所以 S(n!)"

代码如下:

#include<algorithm>
#include<cstring>
#include<cstdio>
#include<iostream>
using namespace std;
typedef long long ll; const int N=1e8+;
const int mod=1e9+;
ll n,tot,ans;
ll prime[N],vis[N];
void get_prime()
{
for (ll i=;i<=n;i++)
{
if (!vis[i]) prime[++tot]=i;
for (ll j=;j<=tot&&prime[j]*i<=n;j++)
{
vis[prime[j]*i]=;
if (i%prime[j]==) break;
}
}
}
ll mul(ll a,ll b)
{
ll res=;
for (;b;b>>=,a=(a+a)%mod) if (b&) res=(res+a)%mod;
return res;
}
ll qpow(ll a,ll b)
{
ll res=;
for (;b;b>>=,a=mul(a,a)%mod) if (b&) res=res*a%mod;
return res;
}
ll solve(ll a,ll b)
{
ll res=;
while (a)
{
a/=b;
res+=a;
}
return res;
}
int main()
{
//scanf("%lld",&n);
n=1e8;
ans=;
get_prime();
for (ll i=;i<=n;i++)
{
if (!vis[i])
{
ll power=solve(n,i);
ans=1ll*ans*(qpow(i,power*)+)%mod;
}
}
printf("%lld",ans);
return ;
}

本博客内容转自http://www.cnblogs.com/LzyRapx/p/8280943.html

[Project Euler 429] Sum of squares of unitary divisors(数论)的更多相关文章

  1. Project Euler 98:Anagramic squares 重排平方数

    Anagramic squares By replacing each of the letters in the word CARE with 1, 2, 9, and 6 respectively ...

  2. Project Euler 44: Find the smallest pair of pentagonal numbers whose sum and difference is pentagonal.

    In Problem 42 we dealt with triangular problems, in Problem 44 of Project Euler we deal with pentago ...

  3. Python练习题 034:Project Euler 006:和平方与平方和之差

    本题来自 Project Euler 第6题:https://projecteuler.net/problem=6 # Project Euler: Problem 6: Sum square dif ...

  4. Python练习题 029:Project Euler 001:3和5的倍数

    开始做 Project Euler 的练习题.网站上总共有565题,真是个大题库啊! # Project Euler, Problem 1: Multiples of 3 and 5 # If we ...

  5. Project Euler 第一题效率分析

    Project Euler: 欧拉计划是一系列挑战数学或者计算机编程问题,解决这些问题需要的不仅仅是数学功底. 启动这一项目的目的在于,为乐于探索的人提供一个钻研其他领域并且学习新知识的平台,将这一平 ...

  6. Python练习题 048:Project Euler 021:10000以内所有亲和数之和

    本题来自 Project Euler 第21题:https://projecteuler.net/problem=21 ''' Project Euler: Problem 21: Amicable ...

  7. Python练习题 047:Project Euler 020:阶乘结果各数字之和

    本题来自 Project Euler 第20题:https://projecteuler.net/problem=20 ''' Project Euler: Problem 20: Factorial ...

  8. Python练习题 045:Project Euler 017:数字英文表达的字符数累加

    本题来自 Project Euler 第17题:https://projecteuler.net/problem=17 ''' Project Euler 17: Number letter coun ...

  9. Python练习题 044:Project Euler 016:乘方结果各个数值之和

    本题来自 Project Euler 第16题:https://projecteuler.net/problem=16 ''' Project Euler 16: Power digit sum 2* ...

随机推荐

  1. shareSDK的初步使用(shareSDK中微信、qq等兼容问题,以及cocoapods支持架构冲突问题的解决)

    第一次使用shareSDK来做第三方分享,可是.昨天一天都是在调试bug,一直错误不断! 先说下我的开发环境: xcode:5.1 真机调试:iPhone5s 我们都知道xcode5.1以后開始是支持 ...

  2. [转]Adobe CC 2018 下载链接 Creative Cloud 2018 - Creative Cloud 2018 – Adobe CC 2018 Download Links

    Creative Cloud 2018 – Adobe CC 2018 Download Links – ALL Languages Adobe CC 2018Direct Downloads Win ...

  3. (转载)Mac系统下利用ADB命令连接android手机并进行文件操作

    Mac系统下利用ADB命令连接android手机并进行文件操作 标签: Mac adb android 2016-03-14 10:09 5470人阅读 评论(1) 收藏 举报  分类: Androi ...

  4. 大神js总结

    http://www.cnblogs.com/tylerdonet/p/5543813.html http://www.codesec.net/list/8/

  5. UVa 12545 Bits Equalizer【贪心】

    题意:给出两个等长的字符串,0可以变成1,?可以变成0和1,可以任意交换s中任意两个字符的位置,问从s变成t至少需要多少次操作 先可以画个草图 发现需要考虑的就是 1---0 0---1 ?---0 ...

  6. 优动漫PAINT-牵牛花画法教程

    喇叭型对画者自身的塑形功力会有较高的要求,作者很靠谱的把他的塑形方式详细呈现了出来~ 对于这样的一个仿真效果的牵牛花完全可以使用优动漫PAINT完成,简单又快捷,软件下载:http://www.don ...

  7. No mapping found for HTTP request with URI [/spring_liu/hello.do] in DispatcherServlet with name 'SpringMVC'

    控制台一直报No mapping found for HTTP request with URI [/spring_liu/hello.do] in DispatcherServlet with na ...

  8. Debian9.5系统DHCP服务器ISC DHCP软件配置说明

    DHCP 全称Dynamic Host configuration protocol, 动态主机配置协议.是一个局域网的网络协议,使用UDP协议工作,它可以为客户机自动分配IP地址.子网掩码以及缺省网 ...

  9. 用jQuery设置多个css样式

    $("#show_one").css({"position":"fixed","top":"0px" ...

  10. 字符串格式时间转Date格式

    /** * 字符串时间格式转 Date 格式 * @param strDate * @return */ public static Date getDateTimeByStringTime(Stri ...