C - Aladdin and the Flying Carpet
#include<bitset>
#include<map>
#include<vector>
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<stack>
#include<queue>
#include<set>
#define inf 0x3f3f3f3f
#define mem(a,x) memset(a,x,sizeof(a)) using namespace std;
typedef long long ll; //输入挂
inline ll in()
{
ll res=;char c;
while((c=getchar())<'' || c>'');
while(c>='' && c<='')res=res*+c-'',c=getchar();
return res;
} const int N=;
ll prime[];
int p;
bitset<N> vis; void init()
{
for(int i=;i<N;i++)
{
if(!vis[i])
{
prime[p++]=i;
for(int j=i+i;j<N;j+=i)
{
vis[j]=;
}
}
}
}
int main()
{
int T = in();
int ii = ;
init();
while(T--)
{
ll area = in(),min_side = in();
if(min_side >= sqrt(area)){
printf("Case %d: %d\n",ii++,);
continue;
}
ll tmp = area;
int ans = ;
for(int i = ;i < p && prime[i]*prime[i] <= area;i++)
{
int cnt = ;
while(area%prime[i] == )
{
area /= prime[i];
cnt++;
}
ans *= (cnt+);
}
if(area != ) ans <<= ;
ans >>= ; //因数的个数除以二就是组数,同时排除了平方根
for(int i = ;i < min_side;i++)
if(tmp%i == ) ans--; //min_side此时是小于sqrt(area)的
printf("Case %d: %d\n",ii++,ans);
}
return ;
}
C - Aladdin and the Flying Carpet的更多相关文章
- LightOJ 1341 - Aladdin and the Flying Carpet (唯一分解定理 + 素数筛选)
http://lightoj.com/volume_showproblem.php?problem=1341 Aladdin and the Flying Carpet Time Limit:3000 ...
- Aladdin and the Flying Carpet
Aladdin and the Flying Carpet https://cn.vjudge.net/contest/288520#problem/C It's said that Aladdin ...
- C - Aladdin and the Flying Carpet 有多少种长方形满足面积为a(<=10^12),且最短边>=b;长方形边长为整数,且一定不可以是正方形。
/** 题目:C - Aladdin and the Flying Carpet 链接:https://vjudge.net/contest/154246#problem/C 题意:有多少种长方形满足 ...
- LightOJ1341 Aladdin and the Flying Carpet —— 唯一分解定理
题目链接:https://vjudge.net/problem/LightOJ-1341 1341 - Aladdin and the Flying Carpet PDF (English) S ...
- Aladdin and the Flying Carpet (LightOJ - 1341)【简单数论】【算术基本定理】【分解质因数】
Aladdin and the Flying Carpet (LightOJ - 1341)[简单数论][算术基本定理][分解质因数](未完成) 标签:入门讲座题解 数论 题目描述 It's said ...
- 数论 C - Aladdin and the Flying Carpet
It's said that Aladdin had to solve seven mysteries before getting the Magical Lamp which summons a ...
- E - Aladdin and the Flying Carpet
It's said that Aladdin had to solve seven mysteries before getting the Magical Lamp which summons a ...
- [LightOJ 1341] Aladdin and the Flying Carpet (算数基本定理(唯一分解定理))
题目链接: https://vjudge.net/problem/LightOJ-1341 题目描述: 问有几种边长为整数的矩形面积等于a,且矩形的短边不小于b 算数基本定理的知识点:https:// ...
- 1341 - Aladdin and the Flying Carpet ---light oj (唯一分解定理+素数筛选)
http://lightoj.com/volume_showproblem.php?problem=1341 题目大意: 给你矩形的面积(矩形的边长都是正整数),让你求最小的边大于等于b的矩形的个数. ...
- LightOJ 1341 Aladdin and the Flying Carpet 数学
题意:给个矩形的面积a,和矩形的最小边长b,问有多少种矩形的方案(不能是正方形) 分析:a可以写成x,y,因为不能是正方形,所以设x<y,那么x<sqrt(a),y>sqrt(a) ...
随机推荐
- window.onerror 错误监听,发到后台
var doc = document.body || document.documentElement; var _onerror = Onerror(''); var Onerror = funct ...
- css定位的元素内层不自动扩高解决
给最外层的CSS加上一行: 1 position: relative; /* 给最外层加上这行 */
- CentOS-7-64bit 下为firefox安装flashplayer
最近更新了Centos 7 还是有一些不习惯的 给ff安flashplayer插件时,按centos 6.x的方法时都无法成功,后来find了一下,才知道firefox还有一个64bit的文件夹: 解 ...
- Android项目中JNI技术生成并调用.so动态库实现详解
生成 jni方式有两种:一种是通过SWIG从C++代码生成过度的java代码:另一种是通过javah的方式从java代码自动生成过度的C++代码.两种方式下的步骤流程正好相反. 第一种方式:由于需要配 ...
- Appium基础——one demo
启动模拟器,启动appium android avd启动模拟器管理 选择一个版本启动 安装appium-client 直接pip install appium-python-client安装 ...
- phpcms v9中的$CATEGORYS栏目数组
首先 如果不能用$CATEGORYS这个数组或掉不出来内容应加入 $CATEGORYS = getcache('category_content_1','commons'); 1.用途 $CATEGO ...
- hdu 2188 悼念512汶川大地震遇难同胞——选拔志愿者(Bash Game)
题意:从0开始捐款,每次不超过m元,首先达到n元的获胜 思路:等同于从n开始,每次取不超过m,首先达到0的获胜.(Bash Game) #include<iostream> #includ ...
- 机器学习 : 高斯混合模型及EM算法
Mixtures of Gaussian 这一讲,我们讨论利用EM (Expectation-Maximization)做概率密度的估计.假设我们有一组训练样本x(1),x(2),...x(m),因为 ...
- Swift下表和方法
本文将同时阐述Swift的方法和下标,因为根据我的理解,从某种程度上讲,下标的本质也是方法. 方法 众所周知,在支持面向对象的语言里,方法一般分为两种:实例方法和类方法(在有的语言中,「类方法」被称为 ...
- P2383 狗哥玩木棒
题目背景 狗哥又趁着语文课干些无聊的事了... 题目描述 现给出一些木棒长度,那么狗哥能否用给出的木棒(木棒全用完)组成一个正方形呢? 输入输出格式 输入格式: 输入文件中的第一行是一个整数n表示测试 ...