/**
题目:C - Aladdin and the Flying Carpet
链接:https://vjudge.net/contest/154246#problem/C
题意:有多少种长方形满足面积为a,且最短边>=b;长方形边长为整数,且一定不可以是正方形。
思路:求出a的素因子以及每个素因子的个数,然后搜索所有满足条件的方法数。
其实可以求出所有<b的方法数,用总的减去它,可以更快,不过更麻烦。
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e6+;
ll prime[maxn];
int z;
vector<ll>v;
int num[];
int cous;
ll a, b;
void init()
{
memset(prime, , sizeof prime);
for(int i = ; i < maxn; i++){
if(prime[i]==){
for(int j = i+i; j < maxn; j+=i){
prime[j] = ;
}
}
}
z = ;
for(int i = ; i < maxn; i++){
if(prime[i]==){
prime[z++] = i;
}
}
/// cout<<"prime number = "<<z<<endl; 78000ge
}
ll ans;
void solve(int h,ll value)
{
if(h==){
if(value>=b&&a/value>=b&&value*value!=a) ans++;
return;
}
for(int i = ; i <= num[h-]; i++){
if(i>){
value*=v[h-];
}
solve(h-,value);
}
}
int main()
{
init();
int T, cas=;
cin>>T;
while(T--)
{
int cnt = ;
scanf("%lld%lld",&a,&b);
v.clear();
ll n = a;
cous = ;
memset(num, , sizeof num);
for(int i = ; i < z&&prime[i]*prime[i]<=n; i++){
if(n%prime[i]==){
v.push_back(prime[i]);
while(n%prime[i]==){
n/=prime[i];
num[cous]++;
}
cous++;
}
}
if(n>){
v.push_back(n);
num[cous++] = ;
}
ans = ;
solve(cous,);
printf("Case %d: %lld\n",cas++,ans/);
}
return ;
}

C - Aladdin and the Flying Carpet 有多少种长方形满足面积为a(<=10^12),且最短边>=b;长方形边长为整数,且一定不可以是正方形。的更多相关文章

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

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

  2. LightOJ1341 Aladdin and the Flying Carpet —— 唯一分解定理

    题目链接:https://vjudge.net/problem/LightOJ-1341 1341 - Aladdin and the Flying Carpet    PDF (English) S ...

  3. Aladdin and the Flying Carpet

    Aladdin and the Flying Carpet https://cn.vjudge.net/contest/288520#problem/C It's said that Aladdin ...

  4. Aladdin and the Flying Carpet (LightOJ - 1341)【简单数论】【算术基本定理】【分解质因数】

    Aladdin and the Flying Carpet (LightOJ - 1341)[简单数论][算术基本定理][分解质因数](未完成) 标签:入门讲座题解 数论 题目描述 It's said ...

  5. 数论 C - Aladdin and the Flying Carpet

    It's said that Aladdin had to solve seven mysteries before getting the Magical Lamp which summons a ...

  6. E - Aladdin and the Flying Carpet

    It's said that Aladdin had to solve seven mysteries before getting the Magical Lamp which summons a ...

  7. LightOJ 1341 Aladdin and the Flying Carpet 数学

    题意:给个矩形的面积a,和矩形的最小边长b,问有多少种矩形的方案(不能是正方形) 分析:a可以写成x,y,因为不能是正方形,所以设x<y,那么x<sqrt(a),y>sqrt(a) ...

  8. LightOJ1341 Aladdin and the Flying Carpet

    题意 给一对数字 a,b ,a是一个长方形的面积,问有多少种整数的边的组合可以组成面积为a的长方形,要求最短的边不得小于b 数据组数T<=4000, a,b<=10^12 Solution ...

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

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

随机推荐

  1. 论文中的state-of-the-art

    最近看了几篇计算机顶会和SCI,摘要里经常出现这个词,我以为是什么算法,查阅的知是“当前最高水平”,我记得老师说不能有这种模糊词语,需要表明提高了多少,看来论文都很水,即便是IEEE,SCI.

  2. Delphi~通过程序窗体句柄获取程序路径

    http://www.cnblogs.com/Jesses/articles/1636323.html 引用PsAPI var  h:HWND;  pid: Cardinal;  pHandle: T ...

  3. Debian、Ubuntu 源列表说明

    转载:http://forum.ubuntu.org.cn/viewtopic.php?t=366506 概貌: 源列表主文件为 /etc/apt/sources.list,另兼取 /etc/apt/ ...

  4. MORMOT数据库连接池

    MORMOT数据库连接池 MORMOT封装了一堆的PROPS控件,用于连接各种数据库. MORMOT的封装是武装到了牙齿的,这堆PROPS控件居然数据库连接池也封装好了.这就为我们省了不少事,笔者非常 ...

  5. javascript快速入门14--DOM基础

    DOM(Document Object Model)——文档对象模型 什么是DOM? Document Object Model (DOM)是HTML和XML文档的编程接口.它提供了上述文档的一种结构 ...

  6. unity GPU bound or CPU bound

    unity判断GPU CPUbound android 用unity profiler 里面的cpu时间 xcode有直接的显示

  7. chrome护眼模式

    chrome护眼模式 使用stylish插件: 学习:https://jingyan.baidu.com/article/b907e627f74df146e6891c67.html 插件下载:http ...

  8. 最小生成树之Prim(普里姆)算法

    关于什么是Prim(普里姆算法)? 在实际生活中,我们常常碰到类似这种一类问题:如果要在n个城市之间建立通信联络网, 则连通n个城市仅仅须要n-1条线路.这时.我们须要考虑这样一个问题.怎样在最节省经 ...

  9. BIN文件如何打开

    有些BIN文件用DAEMON Tools也无法打开 但是UltraISO可以打开,我们看到有Setup.exe,但是如果直接双击无法运行.我们可以先把所有东西都提取出来.   这样之后再点击Setup ...

  10. Digg工程师讲述Digg背后的技术

    虽然最近业绩有所下滑,也出现了一些技术故障,但Digg作为首屈一指的社会化新闻网站,其背后的技术还是值得一探,Digg工程师 Dave Beckett 在今年4月份写一篇名为<How Digg ...