题意:

就是。。。。求a的所有大于b的因子有多少对

算术基本定理求 所有因子 阿欧。。。偷张图。

注意范围 就好  。。。。。

解析:

在1 -1012的范围内求大于b的所有a的因子的对数(有几对)

就等于 在1 -1012的范围内求出a的所有因子 除二  减去  在1 - (b-1)的范围内a的所有因子

#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<vector>
#include<queue>
#include<cmath>
#include<map>
#include<stack>
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long LL;
const int maxn=; LL primes[maxn], vis[maxn];
LL base[maxn], mi[maxn];
int ans = ;
void init()
{
mem(vis,);
for(int i=; i<maxn; i++)
if(!vis[i])
{
primes[ans++] = i;
for(LL j=(LL)i*i; j<maxn; j+=i)
vis[j] = ;
}
} int main()
{
int T;
init();
int m = ;
scanf("%d",&T);
while(T--)
{
LL S, edge;
scanf("%lld%lld",&S,&edge);
LL x = S;
if(edge * edge >= S){
printf("Case %d: 0\n",++m); continue;
}
LL res = , cnt2 = ;
for(int i=; i < ans && primes[i] * primes[i] <= S; i++)
{
LL cnt = ;
while(S % primes[i] == )
{
cnt++;
S /= primes[i]; }
if(S > ){
base[cnt2] = primes[i];
mi[cnt2++] = cnt;
}
}
if(S > )
{
base[cnt2] = S;
mi[cnt2++] = ;
}
LL temp = ;
for(int i=; i<cnt2; i++)
{
res *= (mi[i]+);
if(base[i] < edge)
temp *= mi[i]; }
printf("Case %d: %lld\n",++m,res/ - temp); } return ;
}

LightOJ - 1341 Aladdin and the Flying Carpet (算术基本定理)的更多相关文章

  1. [LightOJ 1341] Aladdin and the Flying Carpet (算数基本定理(唯一分解定理))

    题目链接: https://vjudge.net/problem/LightOJ-1341 题目描述: 问有几种边长为整数的矩形面积等于a,且矩形的短边不小于b 算数基本定理的知识点:https:// ...

  2. LightOJ 1341 Aladdin and the Flying Carpet 算数基本定理

    题目大意:给出面积n,和最短边m,求能形成的矩形的个数(不能为正方形). 题目思路:根据算数基本定理有: 1.每个数n都能被分解为:n=p1^a1*p2^a2*^p3^a3……pn^an(p为素数); ...

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

    http://lightoj.com/volume_showproblem.php?problem=1341 Aladdin and the Flying Carpet Time Limit:3000 ...

  4. LightOJ 1341 - Aladdin and the Flying Carpet

    题目链接:http://lightoj.com/volume_showproblem.php?problem=1341 题意:给你地毯面积和最小可能边的长度,让你求有几种组合的可能. 题解:这题就厉害 ...

  5. LightOJ - 1341 Aladdin and the Flying Carpet 唯一分解定理LightOJ 1220Mysterious Bacteria

    题意: ttt 组数据,第一个给定飞毯的面积为 sss,第二个是毯子的最短的边的长度大于等于这个数,毯子是矩形但不是正方形. 思路: 求出 sss 的所有因子,因为不可能是矩形,所以可以除以 222, ...

  6. lightoj 1341 Aladdin and the Flying Carpet(算术基本定理)题解

    题意:给一个矩形(非正方形)面积a和最小边长b,要求边长均大于b,求这样的矩形有几个 思路:先用到了之前学的质因数分解,还有一个新的公式: 然后我们可以先算出a的所有约数,因为只算约数个数面积重复,所 ...

  7. LightOJ 1341 Aladdin and the Flying Carpet(唯一分解定理)

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

  8. LightOJ 1341 - Aladdin and the Flying Carpet 基本因子分解

    http://www.lightoj.com/volume_showproblem.php?problem=1341 题意:给你长方形的面积a,边最小为b,问有几种情况. 思路:对a进行素因子分解,再 ...

  9. LightOJ 1341 Aladdin and the Flying Carpet【整数分解】

    题目链接: http://lightoj.com/login_main.php?url=volume_showproblem.php?problem=1341 题意: 给定一个数,将其拆分成两个数的乘 ...

随机推荐

  1. php和js字符串的acsii码函数

    简单普及下编码知识: javascript中有charCodeAt(),根据字符查找ascii码. String.fromCharCode(),根据ascii码查找对应的字符. console.log ...

  2. odoo中的ORM操作

    ORM方法简介 OpenERP的关键组件, ORM是一个完整的对象关系映射层,是开发人员不必编写基本的SQL管道. 业务对象被声明继承字models.Models的python类. 这让业务对象在OR ...

  3. 解决System.Runtime.CompilerServices.ExtensionAttribute..ctor 与 ‘ExtensionAttribute’ is ambiguous in the namespace ‘System.Runtime.CompilerServices’ 问题

    从VSS上获取以前的老项目,编译时报System.Runtime.CompilerServices.ExtensionAttribute..ctor 网上写的“删除 Newtonsoft.Json.N ...

  4. php WNMP(Windows+Nginx+Mysql+php)配置笔记

    下载安装 php 修改nginx 文件 参考云盘实例 eclipse php配置服务ip 127.0.0.1:999 以及项目路径(php解析路径)

  5. 1.RapidIO协议概述

    转自https://www.cnblogs.com/liujinggang/p/9925859.html 一.RapidIO背景介绍 RapidIO是由Motorola和Mercury等公司率先倡导的 ...

  6. 解决 java.net.BindException: Address already in use (Bind failed)

    这是因为tomcat未正确关闭导致的端口占用问题 找到报错中被占用的端口kill掉进程即可,一般是8080,也有下面这种8005的 11-Mar-2019 14:46:12.405 SEVERE [m ...

  7. Wechat login authorization(OAuth2.0)

    一.前言 昨天小组开了个会,让我今天实现一个微信网页授权的功能,可以让用户在授权之后无需再次登录既可进入用户授权界面.在这之前我也从没接触过微信公众号开发之类的,也不知道公众号后台是啥样子的,自己所在 ...

  8. HTTP协议冷知识大全

    如果不用HTTPS,HTTP协议如何安全的传输密码信息? HTTP协议是纯文本协议,没有任何加密措施.通过HTTP协议传输的数据都可以在网络上被完全监听.如果用户登陆时将用户名和密码直接明文通过HTT ...

  9. 修改sga_max_size大小后重启数据库报 ORA-00851

    http://blog.itpub.net/30150152/viewspace-1449898/

  10. pair work结对编程(张艺 杨伊)

    一.结对编程人员: 张艺(学号后三位:185) 杨伊(学号后三位:151) 二.这是我们工作的样子:(图片) 三.结对编程优缺点:  优点:  1.结对编程时间紧密,在一定程度上可以督促双方学习,提高 ...