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 ...
随机推荐
- boxworld开发日记2019-6-8
打算做一个类似RimWorld的游戏,这里记录一下历程.首先,简单回顾一下. 2018年12月23日 场景管理,打算使用四叉树,后来发现四叉树在空间组织和内存占用方面并不占优势,之后计划使用地图分块 ...
- Linux安装PHP环境
简介: PHP(外文名:PHP: Hypertext Preprocessor,中文名:“超文本预处理器”)是一种通用开源脚本语言.语法吸收了C语言.Java和Perl的特点,利于学习,使用广泛,主要 ...
- Mybatis的Dao向mapper传多个参数(三种解决方案)转自《super超人》
第一种方案 : DAO层的函数方法 Public User selectUser(String name,String area); 对应的Mapper.xml <select id=" ...
- 支持多种格式的播放器js代码
FLV需要播放器,其它视频格式直接插入相应的代码即可. ------------------------------------- /** *视频播放 by zhensheng@ *参数说明 ...
- Mui使用jquery并且使用点击跳转新窗口
网上好多朋友是这样做的: 全局插入了js代码 mui('body').on('tap', 'a', function () { document.location.href = this.href; ...
- C#模拟百度登录并到指定网站评论回帖(三)
上次说到怎么获取BAIDUID,这个相信很多人都能够拿到就不多说了,今天一连说两个,获取token和raskey 2.利用以上获得的cookie直接访问页面 https://passport.baid ...
- quartz在集群环境下的最终解决方案
在集群环境下,大家会碰到一直困扰的问题,即多个 APP 下如何用 quartz 协调处理自动化 JOB . 大家想象一下,现在有 A , B , C3 台机器同时作为集群服务器对外统一提供 SERVI ...
- Spartan6系列之SelectIO深入详解及高级应用简介
1. 什么是I/O Tile? 对Spartan-6系列FPGA来说,一个IO Tile包括2个IOB.2个ILOGIC.2个OLOGIC.2个IODELAY. 图 1Spartan-6系列 ...
- Linux服务器文件权限被改
阿里云买的ubuntu服务器遭受了不明攻击,导致站点访问不了,折腾了很久,才发现是文件的权限被修改了.然后就是一点点的修改,很是麻烦.服务器的安全要重视呢! 1.修改权限 chmod 755 * -R ...
- Java基本输入输出
Java基本输入输出 基本输入 基本输出 package com.ahabest.demo; public class Test { public static void main(String[] ...