/**
题目: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. angular2学习资源汇总

    文档博客书籍类 官方网站: https://angular.io 中文站点: https://angular.cn Victor的blog(Victor是Angular路由模块的作者): https: ...

  2. Word里如何打出带有上下横杠的大写字母i

    换成新罗马就行了.

  3. Network Connection Lost When Windows 8 Goes To Sleep

    http://www.kapilarya.com/fix-network-connection-lost-when-windows-8-goes-to-sleep http://superuser.c ...

  4. [CSS]滚动条样式设置

    概述 最近项目中需要,将一个页面嵌入在一个webbrower中,这个webrower是定高的,在页面内容超过webbrower高度时,需要以滚动条的形式展现,当时也考虑了使用webbrower的滚动条 ...

  5. access 数据更新语句

    UPDATE YS_POINT AS a, YS_LINE AS b SET a.管线高程 = b.SELEV1WHERE (((a.物探点号)=[b].[起点号]));

  6. 使用Spring Boot集成FastDFS

    原文:http://www.cnblogs.com/ityouknow/p/8298358.html#3893468 上篇文章介绍了如何使用Spring Boot上传文件,这篇文章我们介绍如何使用Sp ...

  7. 利用CMD查看系统硬件信息

    利用CMD查看系统硬件信息对于在windows下查看系统信息大家一定不陌生了,我现在说几个最常用的方法,对命令感兴趣的朋友看看,(给菜鸟看的,老手就不要笑话我了,大家都是从那个时候过来的,^_^).一 ...

  8. docker_usb开发软件部署

    1.docker镜像包  (备注:61提供,带桌面版本) rayosx2.0.2.tar 2.paho-mqtt dnf install git -y git clone https://github ...

  9. postprocessing stack v2

    用了v2和unity2017.3.0f有兼容性问题 在assetbundle的情况下 CopyStd这个shader打不进去 在assetbundle的menafest里面有列但是shader.fin ...

  10. 【转载】tcp窗口滑动以及拥塞控制

    转自:http://blog.chinaunix.net/uid-26275986-id-4109679.html TCP协议作为一个可靠的面向流的传输协议,其可靠性和流量控制由滑动窗口协议保证,而拥 ...