一定要先打表素数,然后进行分解,直接分解是会t的

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#define ll long long
using namespace std;
int const MAX = 1e6 + ;
int p[MAX];
bool u[MAX];
int num, cnt;
ll a, b, tmp; void get_prime()
{
memset(u, false, sizeof(u));
for(int i = ; i <= sqrt(MAX); i++)
if(!u[i])
for(int j = i * i; j <= MAX; j += i)
u[j] = true;
for(int i = ; i <= MAX; i++)
if(!u[i])
p[cnt ++] = i;
} void cal()
{
for(int i = ; i < cnt && p[i] <= sqrt(tmp); i++)
{
int cc = ;
while(tmp % p[i] == )
{
cc ++;
tmp /= p[i];
}
num *= (cc + ); }
if(tmp > ) //如果tmp不能被整分,说明还有一个素数是它的约数,此时cc=1
num *= ;
} int main()
{
int T;
scanf("%d", &T);
cnt = ;
get_prime();
for(int ca = ; ca <= T; ca++)
{
scanf("%lld %lld", &a, &b);
if(a < b * b)
printf("Case %d: 0\n", ca);
else
{
num = ;
tmp = a;
cal();
num /= ;
for(int i = ; i < b; i++)
if(a % i == )
num --;
printf("Case %d: %d\n", ca, num);
}
}
}

light1341 唯一分解定理的更多相关文章

  1. NOIP2009Hankson 的趣味题[唯一分解定理|暴力]

    题目描述 Hanks 博士是 BT (Bio-Tech,生物技术) 领域的知名专家,他的儿子名叫 Hankson.现 在,刚刚放学回家的 Hankson 正在思考一个有趣的问题. 今天在课堂上,老师讲 ...

  2. UVA - 10375 Choose and divide[唯一分解定理]

    UVA - 10375 Choose and divide Choose and divide Time Limit: 1000MS   Memory Limit: 65536K Total Subm ...

  3. uva10375 Choose and Divide(唯一分解定理)

    uva10375 Choose and Divide(唯一分解定理) 题意: 已知C(m,n)=m! / (n!*(m-n!)),输入整数p,q,r,s(p>=q,r>=s,p,q,r,s ...

  4. 1341 - Aladdin and the Flying Carpet ---light oj (唯一分解定理+素数筛选)

    http://lightoj.com/volume_showproblem.php?problem=1341 题目大意: 给你矩形的面积(矩形的边长都是正整数),让你求最小的边大于等于b的矩形的个数. ...

  5. UVA 10375 Choose and divide【唯一分解定理】

    题意:求C(p,q)/C(r,s),4个数均小于10000,答案不大于10^8 思路:根据答案的范围猜测,不需要使用高精度.根据唯一分解定理,每一个数都可以分解成若干素数相乘.先求出10000以内的所 ...

  6. 唯一分解定理 poj 1365

    一行代表一个数 x 给你底数和指数 求x-1的唯一分解定理的底数和指数 从大到小输出 #include<stdio.h> #include<string.h> #include ...

  7. UVA294DIvisors(唯一分解定理+约数个数)

    题目链接 题意:输入两个整数L,U(L <= U <= 1000000000, u - l <= 10000),统计区间[L,U]的整数中哪一个的正约数最多,多个输出最小的那个 本来 ...

  8. POJ1845Sumdiv(求所有因子和 + 唯一分解定理)

    Sumdiv Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 17387   Accepted: 4374 Descripti ...

  9. UVa 10791 Minimum Sum LCM【唯一分解定理】

    题意:给出n,求至少两个正整数,使得它们的最小公倍数为n,且这些整数的和最小 看的紫书--- 用唯一分解定理,n=(a1)^p1*(a2)^p2---*(ak)^pk,当每一个(ak)^pk作为一个单 ...

随机推荐

  1. 生成器的throw和close方法

    def gen_func(): try: yield 1 except Exception as e: pass yield 2 yield 3 yield 4 yield 5 return &quo ...

  2. Handler的postDelayed的实现方法

    暂存,待归纳 https://www.jianshu.com/p/f5f710d55255 https://blog.csdn.net/qingtiantianqing/article/details ...

  3. FLASK-----基本知识(一)

    中文文档(http://docs.jinkan.org/docs/flask/) 英文文档(http://flask.pocoo.org/docs/0.11/) FLASK介绍 Flask是一个基于P ...

  4. SqlServer三种常用窗口函数

    插入数据 ,),(,),(,),(,),(,),(,),(,) ⒈rank()over,跳跃排序,允许并列,并在发生并列时保留名次空缺. select rank() over(order by sco ...

  5. python中的多重循环

    列表中会经常用到多重循环. if __name__=='__main__': names = ['xiaoming','wangwu','lisi'] ages = ['] for name,age ...

  6. Linux只读账号配置【转】

    整个配置的命令如下(主要使用了:Linux bash受限的shell(RESTRICTED SHELL)) 步骤#1.创建只读shell(这步可以省略) ln -s /bin/bash /bin/rb ...

  7. python3+selenium入门12-警告框处理

    在WebDriver中要处理JS生成的alert.confirm以及prompt,需要使用到switch_to_alert()定位到alert/confirm/prompt,然后再使用text.acc ...

  8. python获取windows信息

    转载自http://www.blog.pythonlibrary.org/2010/02/06/more-windows-system-information-with-python/ How to ...

  9. hue报错StructuredException: timed out (code THRIFTSOCKET): None的处理

    通过hue的web界面进行hive的sql查询,无法显示结果并报错timeout 报错如下:[28/Jul/2017 11:23:29 +0800] decorators ERROR error ru ...

  10. Laravel 5.2--git冲突error: Your local changes to the following files would be overwritten by merge:

    今天在服务器上git pull是出现以下错误: error: Your local changes to the following files would be overwritten by mer ...