题目链接: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. 跟我学设计模式视频教程——适配器模式,适配器模式VS装饰模式

    课程视频 适配器模式 适配器模式VS装饰模式 唠嗑 课程笔记 课程笔记 课程代码 课程代码 新课程火热报名中 课程介绍

  2. 关于Javakeywordsynchronized——单例模式的思考

    精彩的设计模式盛宴刚刚落下帷幕.三天的时间.真是学习到了非常多.当中,遗留的非常多的问题.今天就谈谈synchronized这个keyword.关于对synchronizedkeyword的思考是从单 ...

  3. ORA-01733: virtual column not allowed here

    基表: hr.tt  scott.tt  视图1: 基于 hr.tt  union all  scott.tt ---> scott.ttt  视图2: 基于 视图1->scott.ttt ...

  4. excel文件使用html导出

    <table><tr><td>1</td></tr><tr><td>2</td></tr>& ...

  5. Django(1.7 part1)

    django安装: django解压后目录下有一个setup.py文件,在命令行运行python setup.py install,当前前提是已经安装了python才能执行命令,然后用下面命令检查dj ...

  6. cmd 与 网卡(netsh 命令)

    1. 通过命令提示符(cmd)命令连接 Wi-Fi 1.1 连接曾经连接过的 Wi-Fi :: 查看配置的列表(::表示注释) netsh wlan show profile :: 连接 netsh ...

  7. POJ 2386 Lake Counting【BFS】

    题意:给出一个矩形,问有多少块连通的W 当找到W的时候,进行广搜,然后将搜过的W变成点,直到不能再搜,进行下一次广搜,最后搜的次数即为水塘的个数 看的PPT里面讲的是种子填充法. 种子填充算法: 从多 ...

  8. Dbf文件操作

    package cn.com.szhtkj.util; import java.io.File; import java.io.IOException; import java.lang.reflec ...

  9. 运维派 企业面试题4&5 创建10个 用户 ; ping探测主机是否在线

    Linux运维必会的实战编程笔试题(19题) 企业面试题4: 批量创建10个系统帐号oldboy01-oldboy10并设置密码(密码为随机8位字符串). #!/bin/bash # ;i<=; ...

  10. Python学习---Day96

    转载:http://www.cnblogs.com/wupeiqi/articles/6229292.html Scrapy Scrapy是一个为了爬取网站数据,提取结构性数据而编写的应用框架. 其可 ...