CodeForcesGym 100753F Divisions
2015-10-05 19:34
399 查看
Divisions
Time Limit: 2000msMemory 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 = 100001; LL mul(LL a,LL b,LL mod) { if(!a) return 0; return ((a&1)*b%mod + (mul(a>>1,b,mod)<<1)%mod)%mod; } LL quickPow(LL a,LL d,LL n) { LL ret = 1; while(d) { if(d&1) ret = mul(ret,a,n); d >>= 1; a = mul(a,a,n); } return ret; } bool check(LL a,LL d,LL n) { if(n == a) return true; while(~d&1) d >>= 1; LL t = quickPow(a,d,n); while(d < n-1 && t != 1 && t != n-1) { t = mul(t,t,n); d <<= 1; } return (d&1) || t == n-1; } bool isP(LL n) { if(n == 2) return true; if(n < 2 || 0 == (n&1)) return false; static int p[5] = {2,3,7,61,24251}; for(int i = 0; i < 5; ++i) if(!check(p[i],n-1,n)) return false; return true; } LL gcd(LL a,LL b) { if(a < 0) return gcd(-a,b);//特别注意,没这个TLE return b?gcd(b,a%b):a; } LL Pollard_rho(LL n,LL c) { LL i = 1,k = 2,x = rand()%n,y = x; while(true) { x = (mul(x,x,n) + c)%n; LL d = gcd(y - x,n); if(d != 1 && d != n) return d; if(y == x) return n; if(++i == k) { y = x; k <<= 1; } } } 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-1)+1); factorization(p); factorization(n/p); } unordered_map<LL,LL>ump; int main() { LL x; srand(time(0)); while(~scanf("%I64d",&x)){ tot = 0; if(x == 1) { puts("1"); continue; } if(isP(x)){ puts("2"); continue; } factorization(x); ump.clear(); for(int i = 0; i < tot; ++i) ump[Fac[i]]++; unsigned long long ret = 1; for(auto &it:ump) ret *= (it.second + 1); printf("%I64u\n",ret); } return 0; } /* 999999999999999989 100000007700000049 */
View Code
相关文章推荐
- ”Hello World!“的前世今生
- LightOJ 1282 Leading and Trailing
- RecyclerView 解析
- The Shawshank Redemption
- 大数据下的日志--ElasticSearch部分(三)--Bulk,Search操作
- Writing Fast Matlab code 1
- 怎么清洗眼镜片?
- CYC-AVPlayer播放器的简单使用
- static 使用之静态方法
- linux高级技巧:heartbeat+lvs(一)
- Objective-C NSData和NSMutableData
- iOS编程-------UITableViewEdit_move -----> UITableView 编辑
- POJ3565(最大权匹配)
- 大数据下的日志--ElasticSearch部分(二)--结合Java基本操作
- ACM录 之 输入输出。
- CodeForcesGym 100753B Bounty Hunter II
- 12 java.util.LinkedList
- Android-----test----monkeyrunner
- 论文返修(response letter)一些很有用的套话
- Ubuntu升级后apache所有的失败,以解决虚拟文件夹的设置