CodeForcesGym 100753F Divisions
Divisions
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的更多相关文章
- CodeForcesGym 100512D Dynamic LCA
Dynamic LCA Time Limit: 2000ms Memory Limit: 262144KB This problem will be judged on CodeForcesGym. ...
- CodeForcesGym 100517I IQ Test
IQ Test Time Limit: 2000ms Memory Limit: 262144KB This problem will be judged on CodeForcesGym. Orig ...
- CodeForcesGym 100517B Bubble Sort
Bubble Sort Time Limit: 2000ms Memory Limit: 262144KB This problem will be judged on CodeForcesGym. ...
- CodeForcesGym 100517H Hentium Scheduling
Hentium Scheduling Time Limit: 2000ms Memory Limit: 262144KB This problem will be judged on CodeForc ...
- CodeForcesGym 100524J Jingles of a String
Jingles of a String Time Limit: 2000ms Memory Limit: 524288KB This problem will be judged on CodeFor ...
- CodeForcesGym 100524A Astronomy Problem
Astronomy Problem Time Limit: 8000ms Memory Limit: 524288KB This problem will be judged on CodeForce ...
- CodeForcesGym 100212E Long Dominoes
Long Dominoes Time Limit: 1000ms Memory Limit: 65536KB This problem will be judged on CodeForcesGym. ...
- CodeForcesGym 100753K Upside down primes
Upside down primes Time Limit: 2000ms Memory Limit: 262144KB This problem will be judged on CodeForc ...
- CodeForcesGym 100753B Bounty Hunter II
Bounty Hunter II Time Limit: 5000ms Memory Limit: 262144KB This problem will be judged on CodeForces ...
随机推荐
- angularJs模版注入的两种方式
一,声名式注入 1:app.js: var myApp = angular.module("myApp",["ngRoute"]); 2:controller. ...
- MySQL 备份和恢复数据
备份指定数据库的全部表或指定表 mysqldump -u user -h localhost -p [password] db_name[ tbl_name[,tbl_name.......]]> ...
- 最大流增广路(KM算法) HDOJ 1853 Cyclic Tour
题目传送门 /* KM: 相比HDOJ_1533,多了重边的处理,还有完美匹配的判定方法 */ #include <cstdio> #include <cmath> #incl ...
- 解决WebSocket后台报错:The WebSocket session [0] has been closed and no method (apart from close()) may be called on a closed session
场景1: 在后台数据对前台页面进行数据实时推送下,后台采取定时查询数据后,推送给前台页面.在这个过程中,前台页面不停的刷新页面,session在不停的关闭和开启,推送数据时,会出现session连接已 ...
- java 选择排序与冒泡排序
选择排序与冒泡排序的特点与区别 ++++++++++++++++++++++++++++++++++++++++++++++ 选择排序 这一种简单的排序方法,它的基本思想是:R[n]第一次从R[0]~ ...
- Modbus消息帧
两种传输模式中(ASCII和RTU),传输设备以将Modbus消息转为有起点和终点的帧,这就允许接收的设备在消息起始处开始工作,读地址分配信息,判断哪一个设备被选中(广播方式则传给所以设备),判知何时 ...
- dubbo面试题
40 道 Dubbo 面试题及答案:https://blog.csdn.net/BinshaoNo_1/article/details/83024303 (原地址奉上:https://mp.weixi ...
- 【工具】Github
项目目录结构设计与git远程仓库的建立 git码云仓库建立:在码云网站上新建组织和项目. 配置sshkey认证和公钥:命令行ssh-keygen -t rsa -C "xxxxx@xxxxx ...
- PHP开发心得一
1,php获得服务器时间 $time= date('Y-m-d H:i'); echo $time; 一般写法如上,但发现打印出来的时间小时数总数不对,和机器的时间差几个小时.查资料发现,要设定时区. ...
- golang zip 压缩,解压(含目录文件)
每天学习一点go src. 今天学习了zip包的简单使用,实现了含目录的压缩与解压. 写了两个方法,实现了压缩.解压. package ziptest import ( "archive/z ...