/**
题目: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. SonarQube分析报告无法上传的问题

    '); 由于SonarQube5.6 api/ce/submit 接口报以下异常,导致jenkins构建结果显示为失败~: Caused by: java.lang.NullPointerExcept ...

  2. 使用FluentValidation来进行数据有效性验证

    之前我介绍过了使用系统自带的Data Annotations来进行数据有效性验证,今天在CodePlex上逛的时候,发现了一个非常简洁好用的库:FluentValidation 由于非常简洁,就直接拿 ...

  3. Using Dtrace OEL 6.X and Oracle® Solaris 11.3 DTrace (Dynamic Tracing) Guide

    http://www.hhutzler.de/blog/using-dtrace/ https://docs.oracle.com/cd/E53394_01/html/E53395/gkyaz.htm ...

  4. winform 窗体实现增删改查(CRUD)共用模式

    转载:http://www.csframework.com/archive/2/arc-2-20110617-1632.htm 高度封装的编辑窗体 http://www.cnblogs.com/wuh ...

  5. iOS统计项目的代码总行数

    如果要统计ios开发代码,包括头文件的,CD到项目目录下,命令如下 ① 列出每个文件的行数 find . -name "*.m" -or -name "*.h" ...

  6. Qt 之 模仿 QQ登陆界面——样式篇

    一.简述 今天晚上花了半天时间从QQ登录界面抠了些图,顺便加了点样式基本上实现了QQ的登陆界面全部效果.虽不说100%相似,那也有99.99%相似了哈O(∩_∩)O. QQ好像从去年开始,登录界面有了 ...

  7. 理解JS里的偏函数与柯里化

    联系到上篇博客讲的bind完整的语法为: let bound = func.bind(context, arg1, arg2, ...); 可以绑定上下文this和函数的初始参数.举例,我们有个乘法函 ...

  8. Yii2系列教程:安装及Hello World

    http://www.yiiframework.com/ 安装Yii2 打算从头开始,所以,连安装Yii2也稍微写一点吧.安装Yii2最好的方式就是使用composer: composer globa ...

  9. 简单工厂模式 SimpleFactory

     简单工厂模式 SimpleFactory 1.1什么是简单工厂设计模式 简单工厂模式是属于创建型模式,又叫做静态工厂方法(Static Factory Method)模式,但不属于23种GOF设计模 ...

  10. [Javascript] Deep merge in Javascript with Ramda.js mergeDeepWith

    Javascript's Object.assign is shadow merge, loadsh's _.merge is deep merge, but has probem for array ...