Divisions

Time Limit: 2000ms
Memory Limit: 262144KB

This problem will be judged on CodeForcesGym. Original ID: 100753F
64-bit integer IO format: %I64d      Java class name: (Any)

 
解题:大数质因子分解
 #include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = ;
LL mul(LL a,LL b,LL mod) {
if(!a) return ;
return ((a&)*b%mod + (mul(a>>,b,mod)<<)%mod)%mod;
}
LL quickPow(LL a,LL d,LL n) {
LL ret = ;
while(d) {
if(d&) ret = mul(ret,a,n);
d >>= ;
a = mul(a,a,n);
}
return ret;
}
bool check(LL a,LL d,LL n) {
if(n == a) return true;
while(~d&) d >>= ;
LL t = quickPow(a,d,n);
while(d < n- && t != && t != n-) {
t = mul(t,t,n);
d <<= ;
}
return (d&) || t == n-;
}
bool isP(LL n) {
if(n == ) return true;
if(n < || == (n&)) return false;
static int p[] = {,,,,};
for(int i = ; i < ; ++i)
if(!check(p[i],n-,n)) return false;
return true;
}
LL gcd(LL a,LL b) {
if(a < ) return gcd(-a,b);//特别注意,没这个TLE
return b?gcd(b,a%b):a;
}
LL Pollard_rho(LL n,LL c) {
LL i = ,k = ,x = rand()%n,y = x;
while(true) {
x = (mul(x,x,n) + c)%n;
LL d = gcd(y - x,n);
if(d != && d != n) return d;
if(y == x) return n;
if(++i == k) {
y = x;
k <<= ;
}
}
}
LL Fac[maxn],tot;
void factorization(LL n) {
if(isP(n)) {
Fac[tot++] = n;
return;
}
LL p = n;
while(p >= n) p = Pollard_rho(p,rand()%(n-)+);
factorization(p);
factorization(n/p);
}
unordered_map<LL,LL>ump;
int main() {
LL x;
srand(time());
while(~scanf("%I64d",&x)){
tot = ;
if(x == ) {
puts("");
continue;
}
if(isP(x)){
puts("");
continue;
}
factorization(x);
ump.clear();
for(int i = ; i < tot; ++i)
ump[Fac[i]]++;
unsigned long long ret = ;
for(auto &it:ump) ret *= (it.second + );
printf("%I64u\n",ret);
}
return ;
}
/*
999999999999999989
100000007700000049
*/

CodeForcesGym 100753F Divisions的更多相关文章

  1. CodeForcesGym 100512D Dynamic LCA

    Dynamic LCA Time Limit: 2000ms Memory Limit: 262144KB This problem will be judged on CodeForcesGym. ...

  2. CodeForcesGym 100517I IQ Test

    IQ Test Time Limit: 2000ms Memory Limit: 262144KB This problem will be judged on CodeForcesGym. Orig ...

  3. CodeForcesGym 100517B Bubble Sort

    Bubble Sort Time Limit: 2000ms Memory Limit: 262144KB This problem will be judged on CodeForcesGym. ...

  4. CodeForcesGym 100517H Hentium Scheduling

    Hentium Scheduling Time Limit: 2000ms Memory Limit: 262144KB This problem will be judged on CodeForc ...

  5. CodeForcesGym 100524J Jingles of a String

    Jingles of a String Time Limit: 2000ms Memory Limit: 524288KB This problem will be judged on CodeFor ...

  6. CodeForcesGym 100524A Astronomy Problem

    Astronomy Problem Time Limit: 8000ms Memory Limit: 524288KB This problem will be judged on CodeForce ...

  7. CodeForcesGym 100212E Long Dominoes

    Long Dominoes Time Limit: 1000ms Memory Limit: 65536KB This problem will be judged on CodeForcesGym. ...

  8. CodeForcesGym 100753K Upside down primes

    Upside down primes Time Limit: 2000ms Memory Limit: 262144KB This problem will be judged on CodeForc ...

  9. CodeForcesGym 100753B Bounty Hunter II

    Bounty Hunter II Time Limit: 5000ms Memory Limit: 262144KB This problem will be judged on CodeForces ...

随机推荐

  1. Django day 33 vue中使用element-ui的使用,课程的相关介绍,vue绑定图片,课程列表接口,课程详情页面

    一:vue中使用element-ui的使用, 二:课程的相关介绍, 三:vue绑定图片, 四:课程列表接口, 五:课程详情页面

  2. Spring中bean的作用域与生命周期

    在 Spring 中,那些组成应用程序的主体及由 Spring IOC 容器所管理的对象,被称之为 bean.简单地讲,bean 就是由 IOC 容器初始化.装配及管理的对象,除此之外,bean 就与 ...

  3. loadrunner中get和post请求

    loadrunner中可以使用web_url和web_link发送get请求,使web_submit_form和web_sumbit_data发送post请求. 有什么不同呢?推荐使用哪一个? web ...

  4. LuoguP3398 仓鼠找sugar

    竞赛课想找一道水一点的tarjan题,看看这么久没做题手感有没有掉... 结果这题貌似不是tarjan啊...应该是LCA...假的标签!! 一遍过样例+一遍AC祭(好吧这么水的题也没啥好开心的) 大 ...

  5. 洛谷 P2090 数字对

    发现如果给定两个数(a,b),可以用类似辗转相除法在logn的时间内计算出(反向)变到(1,1)的最小步数. 然而并不知道另一个数是多少? 暴力嘛,枚举一下另一个数,反正1000000的nlogn不虚 ...

  6. .net引用System.Data.SQLite操作SQLite

    之所以要做这个笔记,是因为在.NET中使用System.Data.SQLite的时候,遇到了些问题,这些问题是相对于引用其他dll没有遇到过的,所以作个笔记,记录一下. 简单起见,首先建立一个控制台项 ...

  7. 数据传递-------ajaxJson------spring3mvc中使用ajax传json中文乱码解决

    参考来源:http://blog.csdn.net/dangerous_fire/article/details/25904225 第一种解决方法,适用所有情况 因为在controller中返回jso ...

  8. 1393 0和1相等串 鸽笼原理 || 化简dp公式

    http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1393 正解一眼看出来的应该是鸽笼原理.记录每个位置的前缀和,就是dp[i ...

  9. 联想 Vibe Shot(Z90-7) 免recovery 获取ROOT权限 救砖 VIBEUI V3.1_1625

    >>>重点介绍<<< 第一:本刷机包可卡刷可线刷,刷机包比较大的原因是采用同时兼容卡刷和线刷的格式,所以比较大第二:[卡刷方法]卡刷不要解压刷机包,直接传入手机后用 ...

  10. Web性能测试术语

    并发用户: 并发一般分为2种情况.一种是严格意义上的并发,即所有的用户在同一时刻做同一件事情或者操作,这种操作一般指做同一类型的业务.比如在信用卡审批业 务中,一定数目的用户在同一时刻对已经完成的审批 ...