给定A,B,对于A^B的每一个因子,M为其因子的因子数的三次方求和。

容易推导得出A^B的每一个因子都是A的质因子的组合(质因子可重复利用),其因子数自然等于所使用的每个质因子的数量乘积。

假设A由质因子a1,a2,a3组合而成,对应数量为k1,k2,k3,那么A的因子数为(k1+1)*(k2+1)*(k3+1),同理A的因子的因子数为(k1+1)*(k2+1)*k3+1,(k1+1)*k2*(k3+1),k1*(k2+1)*(k3+1),(k1+1)*k2*k3以此类推。

我们可以发现其为(1+2+3...k1+1)*(1+2+3...k2+1)*(1+2+3...k3+1)的展开。对于这里的每一项,我们可以用求和公式(n*(n+1)/2)^2来求解。

对于拆解一个数的质因数,我们只需要枚举到srqt(n)即可,因为至多只有一个质因数大于sqrt(n) n不断做除法剩下的数即是这个质因数,如果有两个质因数x1,x2大于sqrt(n),那一定有n>=x1*x2与x1>sqrt(n) x2>sqrt(n)相悖。

#include <iostream>
#include <cstring>
#include <string>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdio>
#include <algorithm>
#define LL long long
using namespace std;
const LL N = ;
const LL mod = ;
LL cube(LL num)
{
return (num*(num + ) / )%mod*(num*(num + ) / );
}
vector<LL> su;
bool vis[N];
int main() {
//cin.sync_with_stdio(false);
LL a,b;
fill(vis, vis + N, true);
vis[] = vis[] = false;
for(LL i=;i<N;i++)
if (vis[i])
{
su.push_back(i);
for (LL j = i * ; j < N; j *= i)
vis[i] = false;
}
int cas = ;
while (scanf("%lld%lld",&a,&b)!=EOF)
{
map<LL, LL> mp;
for (LL i = ; i < su.size() && su[i]*su[i] <= a; i++)
{
while (a%su[i] == )
cout << su[i] << endl, mp[su[i]]++, a /= su[i];
}
if (a > )mp[a]++;
LL ans = ;
for (map<LL, LL>::iterator it = mp.begin(); it != mp.end(); it++)
{
it->second *= b, it->second++;
it->second %= mod;
//cout << it->second << endl;
ans *= cube(it->second);
ans %= mod;
}
printf("Case %d: %lld\n", cas++, ans);
//cout << "Case " << cas++<<": ";
//cout << ans << endl; } return ;
}

hdu-2421 Deciphering Password 数学姿势的更多相关文章

  1. hdu 2421 Deciphering Password(约数个数问题)

    http://acm.hdu.edu.cn/showproblem.php?pid=2421 A^B 能够写成 p1^e1 * p2^e2 * .....*pk^ek.(A.B <= 10000 ...

  2. HDU 2825 Wireless Password (AC自己主动机,DP)

    pid=2825">http://acm.hdu.edu.cn/showproblem.php? pid=2825 Wireless Password Time Limit: 2000 ...

  3. HDU 4816 Bathysphere(数学)(2013 Asia Regional Changchun)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4816 Problem Description The Bathysphere is a spheric ...

  4. HDU 5584 LCM Walk 数学

    LCM Walk Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5584 ...

  5. HDU 4336 Card Collector 数学期望(容斥原理)

    题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=4336 题意简单,直接用容斥原理即可 AC代码: #include <iostream> ...

  6. HDU 5750 Dertouzos 简单数学

    感悟:这又是zimpha巨出的一场题,然后04成功fst(也就是这题) 实际上还是too young,要努力增加姿势, 分析:直接枚举这些数不好枚举,换一个角度,枚举x*d,也就是d的另一个乘数是多少 ...

  7. HDU 5570 balls 期望 数学

    balls Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5570 De ...

  8. hdu 2825 Wireless Password(ac自己主动机&amp;dp)

    Wireless Password Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others ...

  9. hdu 4710 Balls Rearrangement (数学思维)

    意甲冠军:那是,  从数0-n小球进入相应的i%a箱号.然后买一个新的盒子. 今天的总合伙人b一个盒子,Bob试图把球i%b箱号. 求复位的最小成本. 每次移动的花费为y - x ,即移动前后盒子编号 ...

随机推荐

  1. Spring 学习历程(二)

    JUnit测试 maven导入包 <!-- https://mvnrepository.com/artifact/junit/junit --> <dependency> &l ...

  2. Python3 tkinter基础 Listbox for+insert 将list中元素导入listbox中

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

  3. for和while循环的区别

    区别:for循环,就是遍历某一对象,通俗说就是根据循环次数限制做多少次重复操作.while循环,是当满足什么条件的时候,才做某种操作. for为遍历循环 while为直到循环

  4. 3. Elements of a Test Plan

    https://jmeter.apache.org/usermanual/test_plan.html This section describes the different parts of a ...

  5. HTTP协议请求类型介绍

    HTTP协议中共定义了八种方法或者叫"动作"来表明对Request-URI指定的资源的不同操作方式,具体介绍如下: OPTIONS: 返回服务器针对特定资源所支持的HTTP请求方法 ...

  6. Tutorials on training the Skip-thoughts vectors for features extraction of sentence.

    Tutorials on training the Skip-thoughts vectors for features extraction of sentence.  1. Send emails ...

  7. 【转载】大连商品交易所-新套利撮合算法FAQ

    原文网址:http://www.dce.com.cn/dalianshangpin/yw/fw/ywzy/jyywzy/498201/1500371/index.html   大连商品交易所 新套利撮 ...

  8. Linux中.rar文件解压

    1. 下载: https://www.rarlab.com/download.htm 我下载的是RAR 5.61 for Linux x64 2. 安装: 解压:tar -zxvf rarlinux- ...

  9. js实例分析JavaScript中的事件委托和事件绑定

    我们在学习JavaScript中,难免都会去网上查一些资料.也许偶尔就会遇到“事件委托”(也有的称我“事件代理”,这里不评论谁是谁非.以下全部称为“事件委托”),尤其是在查JavaScript的事件处 ...

  10. 并发编程之IO模型

    一.阻塞IO(blocking IO) from concurrent.futures import ThreadPoolExecutor import socket server = socket. ...